replace $PWD in unexpand

This commit is contained in:
Lilian Jónsdóttir 2024-06-19 16:35:40 -07:00
parent 00cee25075
commit 5942eee85d

View file

@ -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
}