88 lines
1.7 KiB
Go
88 lines
1.7 KiB
Go
package main
|
||
|
||
import (
|
||
"time"
|
||
|
||
"github.com/fatih/color"
|
||
)
|
||
|
||
var prompts = []func() *ColorString{ps1, ps2, ps3, ps4, ps5}
|
||
|
||
func prompt() *ColorString {
|
||
// width, _, err := terminal.GetSize(int(os.Stdin.Fd()))
|
||
// if err != nil {
|
||
// return ">"
|
||
// }
|
||
|
||
return ps1()
|
||
|
||
// for _, pfunc := range prompts {
|
||
// prompt := pfunc()
|
||
// if prompt.Len()+inputBuffer.Len() < width {
|
||
// return prompt.String()
|
||
// }
|
||
// }
|
||
}
|
||
|
||
func ps1() *ColorString {
|
||
p := new(ColorString)
|
||
p.Append(time.Now().Format("15:04:05"), color.FgRed)
|
||
p.Append(" • ")
|
||
|
||
p.Append(debugInfo, color.FgMagenta)
|
||
if len(debugInfo) > 0 {
|
||
p.Append(" • ")
|
||
}
|
||
|
||
p.Append(env("USER"), color.FgGreen)
|
||
p.Append(" • ")
|
||
p.Append(host(), color.FgYellow)
|
||
p.Append(" • ")
|
||
p.Append(wd(), color.FgBlue)
|
||
p.Append(" ❯", color.FgRed)
|
||
p.Append("❯", color.FgYellow)
|
||
p.Append("❯ ", color.FgGreen)
|
||
return p
|
||
}
|
||
|
||
func ps2() *ColorString {
|
||
p := new(ColorString)
|
||
p.Append(env("USER"), color.FgGreen)
|
||
p.Append(" • ")
|
||
p.Append(host(), color.FgYellow)
|
||
p.Append(" • ")
|
||
p.Append(wd(), color.FgBlue)
|
||
p.Append(" ❯", color.FgRed)
|
||
p.Append("❯", color.FgYellow)
|
||
p.Append("❯ ", color.FgGreen)
|
||
return p
|
||
}
|
||
|
||
func ps3() *ColorString {
|
||
p := new(ColorString)
|
||
p.Append(env("USER"), color.FgGreen)
|
||
p.Append(" • ")
|
||
p.Append(wd(), color.FgBlue)
|
||
p.Append(" ❯", color.FgRed)
|
||
p.Append("❯", color.FgYellow)
|
||
p.Append("❯ ", color.FgGreen)
|
||
return p
|
||
}
|
||
|
||
func ps4() *ColorString {
|
||
p := new(ColorString)
|
||
p.Append(wd(), color.FgBlue)
|
||
p.Append(" ❯", color.FgRed)
|
||
p.Append("❯", color.FgYellow)
|
||
p.Append("❯ ", color.FgGreen)
|
||
return p
|
||
}
|
||
|
||
func ps5() *ColorString {
|
||
p := new(ColorString)
|
||
p.Append(" ❯", color.FgRed)
|
||
p.Append("❯", color.FgYellow)
|
||
p.Append("❯ ", color.FgGreen)
|
||
return p
|
||
}
|