Correct abbreviation of the home directory (#241)

The path has to start with the home directory to be shortened to `~`.
Previously a user named `user` would see `/media/backup~/files` when
browsing `/media/backup/home/user/files`.
This commit is contained in:
arolle authored and gokcehan committed 2019-10-07 22:30:52 +03:00
1 parent ff4c36565c
commit 7b89126e04
1 file changed
+5 -3
+5 -3
View File
@@ -557,9 +557,11 @@ func (ui *ui) loadFileInfo(nav *nav) {
func (ui *ui) drawPromptLine(nav *nav) {
fg, bg := termbox.ColorDefault, termbox.ColorDefault
dir := nav.currDir()
pwd := strings.Replace(dir.path, gUser.HomeDir, "~", -1)
pwd := nav.currDir().path
nohome := strings.TrimPrefix(pwd, gUser.HomeDir)
if len(nohome) < len(pwd) {
pwd = "~/" + nohome
}
pwd = filepath.Clean(pwd)
var fname string