don't replace workdir anymore
This commit is contained in:
parent
1a9e64d473
commit
26f5f383ce
|
@ -11,14 +11,12 @@ import (
|
||||||
// $HOME -> ~
|
// $HOME -> ~
|
||||||
// $PWD -> .
|
// $PWD -> .
|
||||||
// workdir -> .
|
// workdir -> .
|
||||||
func UnExpand(dir, workdir string) (outdir string) {
|
func UnExpand(dir string) (outdir string) {
|
||||||
outdir = filepath.Clean(dir)
|
outdir = filepath.Clean(dir)
|
||||||
home := os.Getenv("HOME")
|
home := os.Getenv("HOME")
|
||||||
|
|
||||||
if pwd, err := os.Getwd(); err == nil && home != pwd {
|
if pwd, err := os.Getwd(); 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)
|
||||||
|
|
|
@ -279,7 +279,7 @@ func (m model) header() string {
|
||||||
default:
|
default:
|
||||||
mode = m.mode.String()
|
mode = m.mode.String()
|
||||||
if m.workdir != "" {
|
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))
|
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
|
return false
|
||||||
} */
|
} */
|
||||||
|
|
||||||
func newRow(file files.File, workdir string) table.Row {
|
func newRow(file files.File) table.Row {
|
||||||
var t, b string
|
var t, b string
|
||||||
t = humanize.Time(file.Date())
|
t = humanize.Time(file.Date())
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
|
@ -329,7 +329,7 @@ func newRow(file files.File, workdir string) table.Row {
|
||||||
}
|
}
|
||||||
return table.Row{
|
return table.Row{
|
||||||
dirs.UnEscape(file.Name()),
|
dirs.UnEscape(file.Name()),
|
||||||
dirs.UnExpand(filepath.Dir(file.Path()), workdir),
|
dirs.UnExpand(filepath.Dir(file.Path())),
|
||||||
t,
|
t,
|
||||||
b,
|
b,
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ func newRow(file files.File, workdir string) table.Row {
|
||||||
|
|
||||||
func (m *model) freshRows(preselected bool) (rows []table.Row) {
|
func (m *model) freshRows(preselected bool) (rows []table.Row) {
|
||||||
for _, f := range m.files {
|
for _, f := range m.files {
|
||||||
r := newRow(f, m.workdir)
|
r := newRow(f)
|
||||||
|
|
||||||
if !m.readonly {
|
if !m.readonly {
|
||||||
r = append(r, getCheck(preselected))
|
r = append(r, getCheck(preselected))
|
||||||
|
@ -474,7 +474,7 @@ func (m *model) sort() {
|
||||||
slices.SortStableFunc(m.files, m.sorting.Sorter())
|
slices.SortStableFunc(m.files, m.sorting.Sorter())
|
||||||
var rows []table.Row
|
var rows []table.Row
|
||||||
for _, file := range m.files {
|
for _, file := range m.files {
|
||||||
r := newRow(file, m.workdir)
|
r := newRow(file)
|
||||||
if !m.readonly {
|
if !m.readonly {
|
||||||
r = append(r, getCheck(m.selected[file.String()]))
|
r = append(r, getCheck(m.selected[file.String()]))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue