new prompt!!
j3s j3s@c3f.net
Tue, 17 Nov 2020 20:44:38 -0600
2 files changed,
10 insertions(+),
8 deletions(-)
M
bin/prompt.go
→
bin/prompt.go
@@ -3,9 +3,8 @@
import ( "fmt" "os" + "os/exec" "strings" - "syscall" - "time" ) func main() {@@ -16,12 +15,15 @@ var parts []string
if strings.HasPrefix(cwd, home) { cwd = "~" + cwd[len(home):] } - var sysinfo syscall.Sysinfo_t - syscall.Sysinfo(&sysinfo) - uptime := time.Duration(sysinfo.Uptime) * time.Second - fmt.Printf("\033[38;5;162m[%d:%02d:%02d] %s\033[0m ", int64(uptime.Hours()), - int64(uptime.Minutes()) % 60, int64(uptime.Seconds()) % 60, - host) + + out, err := exec.Command("git", "branch", "--show-current").Output() + if err != nil { + out = []byte("^(;,;)^\n") + } + branchname := strings.TrimSuffix(string(out), "\n") + + fmt.Printf("\033[38;5;162m[%s]\033[0m ", host) + fmt.Printf("%s ", branchname) parts = strings.Split(cwd, "/") for i, part := range parts {