Ability to customize filename truncating (#417)
* Add truncatechar option * Add ability to set truncatechar via `set` command * Add completion for truncatechar option * Actually use truncatechar option when truncating * Add truncatechar option to docs
This commit is contained in:
parent
9880104c12
commit
d0cd181eb6
@ -140,6 +140,7 @@ var (
|
||||
"shellopts",
|
||||
"sortby",
|
||||
"timefmt",
|
||||
"truncatechar",
|
||||
}
|
||||
)
|
||||
|
||||
|
1
doc.go
1
doc.go
@ -136,6 +136,7 @@ The following options can be used to customize the behavior of lf:
|
||||
shellopts string (default '')
|
||||
sortby string (default 'natural')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
|
||||
The following variables are exported for shell commands:
|
||||
|
||||
|
@ -139,6 +139,7 @@ The following options can be used to customize the behavior of lf:
|
||||
shellopts string (default '')
|
||||
sortby string (default 'natural')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
|
||||
The following variables are exported for shell commands:
|
||||
|
||||
|
2
eval.go
2
eval.go
@ -314,6 +314,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
app.ui.sort()
|
||||
case "timefmt":
|
||||
gOpts.timefmt = e.val
|
||||
case "truncatechar":
|
||||
gOpts.truncatechar = e.val
|
||||
default:
|
||||
app.ui.echoerrf("unknown option: %s", e.opt)
|
||||
return
|
||||
|
2
opts.go
2
opts.go
@ -55,6 +55,7 @@ var gOpts struct {
|
||||
promptfmt string
|
||||
shell string
|
||||
timefmt string
|
||||
truncatechar string
|
||||
ratios []int
|
||||
hiddenfiles []string
|
||||
info []string
|
||||
@ -93,6 +94,7 @@ func init() {
|
||||
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f\033[0m"
|
||||
gOpts.shell = gDefaultShell
|
||||
gOpts.timefmt = time.ANSIC
|
||||
gOpts.truncatechar = "~"
|
||||
gOpts.ratios = []int{1, 2, 3}
|
||||
gOpts.hiddenfiles = []string{".*"}
|
||||
gOpts.info = nil
|
||||
|
4
ui.go
4
ui.go
@ -345,7 +345,7 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b
|
||||
|
||||
if w > win.w-3 {
|
||||
s = runeSliceWidthRange(s, 0, win.w-4)
|
||||
s = append(s, '~')
|
||||
s = append(s, []rune(gOpts.truncatechar)...)
|
||||
} else {
|
||||
for i := 0; i < win.w-3-w; i++ {
|
||||
s = append(s, ' ')
|
||||
@ -359,7 +359,7 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b
|
||||
s = runeSliceWidthRange(s, 0, win.w-3-len(info)-lnwidth)
|
||||
} else {
|
||||
s = runeSliceWidthRange(s, 0, win.w-4-len(info)-lnwidth)
|
||||
s = append(s, '~')
|
||||
s = append(s, []rune(gOpts.truncatechar)...)
|
||||
}
|
||||
for _, r := range info {
|
||||
s = append(s, r)
|
||||
|
Loading…
Reference in New Issue
Block a user