summaryrefslogtreecommitdiff
path: root/formatENV.go
diff options
context:
space:
mode:
Diffstat (limited to 'formatENV.go')
-rw-r--r--formatENV.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/formatENV.go b/formatENV.go
index ea2931c..6a2ab79 100644
--- a/formatENV.go
+++ b/formatENV.go
@@ -3,6 +3,7 @@ package env
import (
"errors"
"fmt"
+ "path/filepath"
"strings"
)
@@ -39,6 +40,11 @@ func formatENV() (string, error) {
// don't write out anything defined globally
continue
}
+ // turns "/home/user/" into ~/
+ relpath, err := filepath.Rel(envPB.HomeDir, c.Value)
+ if err == nil {
+ c.Value = filepath.Join("~", relpath)
+ }
line := fmt.Sprintf("%s=%s", c.Var, c.Value)
out += line + "\n"
}