replace $PWD in unexpand
This commit is contained in:
parent
00cee25075
commit
5942eee85d
|
@ -12,10 +12,18 @@ import (
|
||||||
func UnExpand(dir string) (outdir string) {
|
func UnExpand(dir string) (outdir string) {
|
||||||
var (
|
var (
|
||||||
home = os.Getenv("HOME")
|
home = os.Getenv("HOME")
|
||||||
|
pwd string
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
outdir = filepath.Clean(dir)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue