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:
parent
ff4c36565c
commit
7b89126e04
8
ui.go
8
ui.go
@ -557,9 +557,11 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
func (ui *ui) drawPromptLine(nav *nav) {
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||||
|
|
||||||
dir := nav.currDir()
|
pwd := nav.currDir().path
|
||||||
|
nohome := strings.TrimPrefix(pwd, gUser.HomeDir)
|
||||||
pwd := strings.Replace(dir.path, gUser.HomeDir, "~", -1)
|
if len(nohome) < len(pwd) {
|
||||||
|
pwd = "~/" + nohome
|
||||||
|
}
|
||||||
pwd = filepath.Clean(pwd)
|
pwd = filepath.Clean(pwd)
|
||||||
|
|
||||||
var fname string
|
var fname string
|
||||||
|
Loading…
Reference in New Issue
Block a user