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 2019-10-07 21:30:52 +02:00 committed by gokcehan
parent ff4c36565c
commit 7b89126e04

8
ui.go
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