From effd02865887aeb5b88f8a26a0188d7ee94d0b7b Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Wed, 1 Dec 2021 18:30:03 -0400 Subject: [PATCH] fix: substitution of home dir to ~ when names in path match it fixes edge cases like `/mnt/home/user` --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 32c0e14..65fa640 100644 --- a/main.go +++ b/main.go @@ -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" {