small pixel drawing of a pufferfish dotfiles

new prompt!!
j3s j3s@c3f.net
Tue, 17 Nov 2020 20:44:38 -0600
commit

61b93ae1abae19f1a4e5db3ec101bb272365abfd

parent

4362b0cf0f55155f1b89d5f8aaf7396e76ec1436

2 files changed, 10 insertions(+), 8 deletions(-)

jump to
M bin/prompt.gobin/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 {