From 5942eee85da3161865fa004d0c6337088151f4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 19 Jun 2024 16:35:40 -0700 Subject: [PATCH] replace $PWD in unexpand --- internal/dirs/dirs.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 55d797f..c43a61f 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -12,10 +12,18 @@ import ( func UnExpand(dir string) (outdir string) { var ( home = os.Getenv("HOME") + pwd string + err error ) outdir = filepath.Clean(dir) - outdir = strings.ReplaceAll(outdir, home, "~") + + pwd, err = os.Getwd() + if err == nil { + outdir = strings.Replace(outdir, pwd, ".", 1) + } + + outdir = strings.Replace(outdir, home, "~", 1) return }