diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 5e721eb..9ef7ff7 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -11,14 +11,12 @@ import ( // $HOME -> ~ // $PWD -> . // workdir -> . -func UnExpand(dir, workdir string) (outdir string) { +func UnExpand(dir string) (outdir string) { outdir = filepath.Clean(dir) home := os.Getenv("HOME") if pwd, err := os.Getwd(); err == nil && home != pwd { outdir = strings.Replace(outdir, pwd, ".", 1) - } else if workdir != "" { - outdir = strings.Replace(outdir, workdir, "", 1) } outdir = strings.Replace(outdir, home, "~", 1) diff --git a/internal/tables/tables.go b/internal/tables/tables.go index 4243681..e4aec7f 100644 --- a/internal/tables/tables.go +++ b/internal/tables/tables.go @@ -279,7 +279,7 @@ func (m model) header() string { default: mode = m.mode.String() if m.workdir != "" { - mode += fmt.Sprintf(" in %s ", dirs.UnExpand(m.workdir, "")) + mode += fmt.Sprintf(" in %s ", dirs.UnExpand(m.workdir)) } } mode += fmt.Sprintf(" %s %s", dot, strings.Join(select_keys, wide_dot)) @@ -319,7 +319,7 @@ func (m model) selectedFiles() (outfile files.Files) { return false } */ -func newRow(file files.File, workdir string) table.Row { +func newRow(file files.File) table.Row { var t, b string t = humanize.Time(file.Date()) if file.IsDir() { @@ -329,7 +329,7 @@ func newRow(file files.File, workdir string) table.Row { } return table.Row{ dirs.UnEscape(file.Name()), - dirs.UnExpand(filepath.Dir(file.Path()), workdir), + dirs.UnExpand(filepath.Dir(file.Path())), t, b, } @@ -337,7 +337,7 @@ func newRow(file files.File, workdir string) table.Row { func (m *model) freshRows(preselected bool) (rows []table.Row) { for _, f := range m.files { - r := newRow(f, m.workdir) + r := newRow(f) if !m.readonly { r = append(r, getCheck(preselected)) @@ -474,7 +474,7 @@ func (m *model) sort() { slices.SortStableFunc(m.files, m.sorting.Sorter()) var rows []table.Row for _, file := range m.files { - r := newRow(file, m.workdir) + r := newRow(file) if !m.readonly { r = append(r, getCheck(m.selected[file.String()])) }