my dotz
0

Configure Feed

Select the types of activity you want to include in your feed.

remove osx prompt

-41
-41
bin/prompt_osx.go
··· 1 - package main 2 - 3 - import ( 4 - "fmt" 5 - "os" 6 - "strings" 7 - "golang.org/x/sys/unix" 8 - "time" 9 - ) 10 - 11 - func main() { 12 - cwd, _ := os.Getwd() 13 - host, _ := os.Hostname() 14 - home := os.Getenv("HOME") 15 - var parts []string 16 - if strings.HasPrefix(cwd, home) { 17 - cwd = "~" + cwd[len(home):] 18 - } 19 - // Maybe handle this and drop into failure if leenux 20 - bootTime, _ := unix.SysctlTimeval("kern.boottime") 21 - now := time.Now().Unix() 22 - uptimeSeconds := now - bootTime.Sec 23 - 24 - uptime := time.Duration(uptimeSeconds) * time.Second 25 - fmt.Printf("\033[38;5;162m[%d:%02d:%02d] %s\033[0m ", int64(uptime.Hours()), 26 - int64(uptime.Minutes()) % 60, int64(uptime.Seconds()) % 60, 27 - host) 28 - 29 - parts = strings.Split(cwd, "/") 30 - for i, part := range parts { 31 - if i == len(parts)-1 { 32 - fmt.Printf("%s", part) 33 - } else { 34 - if len(part) != 0 { 35 - fmt.Printf("%c/", part[0]) 36 - } else { 37 - fmt.Printf("/") 38 - } 39 - } 40 - } 41 - }