fix: substitution of home dir to ~ when names in path match it

fixes edge cases like `/mnt/home/user`
dev
TorchedSammy 2021-12-01 18:30:03 -04:00
parent 4a517bde5e
commit effd028658
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 3 additions and 1 deletions

View File

@ -230,7 +230,9 @@ func fmtPrompt() string {
host, _ := os.Hostname()
cwd, _ := os.Getwd()
cwd = strings.Replace(cwd, curuser.HomeDir, "~", 1)
if strings.HasPrefix(cwd, curuser.HomeDir) {
cwd = "~" + strings.TrimPrefix(cwd, curuser.HomeDir)
}
username := curuser.Username
// this will be baked into binary since GOOS is a constant
if runtime.GOOS == "windows" {