initial commit [141.14.129.234,mike]
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// banner is the colored startup line: name/"v"/info white-bold, version yellow,
|
||||
// path green.
|
||||
func banner() string {
|
||||
if useColor {
|
||||
wb := cBold + cWhite
|
||||
return fmt.Sprintf("%smgsh%s %sv%s%s%s%s %s%s,%s %s%s%s",
|
||||
wb, cReset, // mgsh
|
||||
wb, cReset, cYellow, VERSION, cReset, // v (white) + version (yellow)
|
||||
wb, INFO, cReset, // mwx'2026, (white)
|
||||
cGreen, BASE, cReset) // path (green)
|
||||
}
|
||||
return fmt.Sprintf("mgsh v%s %s, %s", VERSION, INFO, BASE)
|
||||
}
|
||||
|
||||
func promptString() string {
|
||||
if useColor {
|
||||
return coloredPrompt()
|
||||
}
|
||||
return plainPrompt()
|
||||
}
|
||||
|
||||
func plainPrompt() string {
|
||||
base := filepath.Base(BASE)
|
||||
if PRJ != "" && isDir(BASE+"/"+PRJ) {
|
||||
p := base + "/" + PRJ + BPLSTATE
|
||||
if BRANCH != "" {
|
||||
p += " (" + BRANCH
|
||||
if DIRTY {
|
||||
p += "*"
|
||||
}
|
||||
p += ")"
|
||||
}
|
||||
return p + " > "
|
||||
}
|
||||
return base + " > "
|
||||
}
|
||||
|
||||
func coloredPrompt() string {
|
||||
var b strings.Builder
|
||||
b.WriteString(cBold + cPurple + "< " + cReset)
|
||||
b.WriteString(cCyan + filepath.Base(BASE) + cReset)
|
||||
if PRJ != "" && isDir(BASE+"/"+PRJ) {
|
||||
b.WriteString(cBold + cWhite + "/" + cReset + cBold + cGreen + PRJ + cReset)
|
||||
if BPLSTATE != "" {
|
||||
b.WriteString(cRed + BPLSTATE + cReset)
|
||||
}
|
||||
if BRANCH != "" {
|
||||
b.WriteString(cGray + " (" + cReset + cCyan + BRANCH + cReset)
|
||||
if DIRTY {
|
||||
b.WriteString(cRed + "*" + cReset)
|
||||
}
|
||||
b.WriteString(cGray + ")" + cReset)
|
||||
}
|
||||
}
|
||||
b.WriteString(" " + cBold + cPurple + ">" + cReset + " ")
|
||||
return b.String()
|
||||
}
|
||||
Reference in New Issue
Block a user