display workdir in header if used
and truncate in table view
This commit is contained in:
parent
b60469887e
commit
f859631f4e
|
@ -12,27 +12,23 @@ import (
|
||||||
// $PWD -> .
|
// $PWD -> .
|
||||||
// workdir -> .
|
// workdir -> .
|
||||||
func UnExpand(dir, workdir string) (outdir string) {
|
func UnExpand(dir, workdir string) (outdir string) {
|
||||||
var (
|
|
||||||
home = os.Getenv("HOME")
|
|
||||||
pwd string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
outdir = filepath.Clean(dir)
|
outdir = filepath.Clean(dir)
|
||||||
|
home := os.Getenv("HOME")
|
||||||
|
|
||||||
if workdir != "" {
|
if pwd, err := os.Getwd(); err == nil && home != pwd {
|
||||||
outdir = strings.Replace(outdir, workdir, ".", 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
pwd, err = os.Getwd()
|
|
||||||
if err == nil && home != pwd {
|
|
||||||
outdir = strings.Replace(outdir, pwd, ".", 1)
|
outdir = strings.Replace(outdir, pwd, ".", 1)
|
||||||
|
} else if workdir != "" {
|
||||||
|
outdir = strings.Replace(outdir, workdir, "", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
outdir = strings.Replace(outdir, home, "~", 1)
|
outdir = strings.Replace(outdir, home, "~", 1)
|
||||||
|
|
||||||
outdir = UnEscape(outdir)
|
outdir = UnEscape(outdir)
|
||||||
|
|
||||||
|
if outdir == "" {
|
||||||
|
outdir = "/"
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ type model struct {
|
||||||
readonly bool
|
readonly bool
|
||||||
termheight int
|
termheight int
|
||||||
mode modes.Mode
|
mode modes.Mode
|
||||||
|
subtitle string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: reconcile trash.Info and files.File into an interface so I can shorten this up
|
// TODO: reconcile trash.Info and files.File into an interface so I can shorten this up
|
||||||
|
@ -134,6 +135,7 @@ func newFilesModel(fs files.Files, width, height int, readonly, preselected bool
|
||||||
readonly: readonly,
|
readonly: readonly,
|
||||||
mode: modes.Trashing,
|
mode: modes.Trashing,
|
||||||
selected: map[int]bool{},
|
selected: map[int]bool{},
|
||||||
|
subtitle: workdir,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -339,6 +341,9 @@ func (m model) header() string {
|
||||||
mode = strings.Join(keys, wide_dot)
|
mode = strings.Join(keys, wide_dot)
|
||||||
default:
|
default:
|
||||||
mode = m.mode.String()
|
mode = m.mode.String()
|
||||||
|
if m.subtitle != "" {
|
||||||
|
mode += fmt.Sprintf(" in %s ", dirs.UnExpand(m.subtitle, ""))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mode += fmt.Sprintf(" %s %s", dot, strings.Join(select_keys, wide_dot))
|
mode += fmt.Sprintf(" %s %s", dot, strings.Join(select_keys, wide_dot))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue