22 lines
295 B
Go
22 lines
295 B
Go
|
package dirs
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// UnExpand unexpands some directory shortcuts
|
||
|
//
|
||
|
// $HOME -> ~
|
||
|
func UnExpand(dir string) (outdir string) {
|
||
|
var (
|
||
|
home = os.Getenv("HOME")
|
||
|
)
|
||
|
|
||
|
outdir = filepath.Clean(dir)
|
||
|
outdir = strings.ReplaceAll(outdir, home, "~")
|
||
|
|
||
|
return
|
||
|
}
|