From d07d474b53d0b57a2e334fef2de82e6ebafe2862 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Mon, 8 May 2023 04:30:01 +0200 Subject: [PATCH] fix: wrong aliasing when home is prefix of another folder --- segment-cwd.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/segment-cwd.go b/segment-cwd.go index 7f2b2c4d..6945c86c 100644 --- a/segment-cwd.go +++ b/segment-cwd.go @@ -105,7 +105,13 @@ func cwdToPathSegments(p *powerline, cwd string) []pathSegment { pathSeparator := string(os.PathSeparator) pathSegments := make([]pathSegment, 0) - if strings.HasPrefix(cwd, p.userInfo.HomeDir) { + if cwd == p.userInfo.HomeDir { + pathSegments = append(pathSegments, pathSegment{ + path: "~", + home: true, + }) + cwd = "" + } else if strings.HasPrefix(cwd, p.userInfo.HomeDir+pathSeparator) { pathSegments = append(pathSegments, pathSegment{ path: "~", home: true,