diff --git a/comp.go b/comp.go index da1a639..7d4d374 100644 --- a/comp.go +++ b/comp.go @@ -44,15 +44,15 @@ var ( } gOptWords = []string{ + "dirfirst", + "nodirfirst", + "dirfirst!", "hidden", "nohidden", "hidden!", "preview", "nopreview", "preview!", - "dirfirst", - "nodirfirst", - "dirfirst!", "scrolloff", "tabstop", "ifs", @@ -60,6 +60,7 @@ var ( "shell", "showinfo", "sortby", + "timefmt", "ratios", } ) diff --git a/doc.go b/doc.go index 7d035aa..afe817f 100644 --- a/doc.go +++ b/doc.go @@ -45,9 +45,9 @@ The following commands are provided by lf without default keybindings. The following options can be used to customize the behavior of lf. + dirfirst bool (default on) hidden bool (default off) preview bool (default on) - dirfirst bool (default on) scrolloff int (default 0) tabstop int (default 8) ifs string (default "") (not exported if empty) @@ -55,6 +55,7 @@ The following options can be used to customize the behavior of lf. shell string (default "$SHELL") showinfo string (default "none") sortby string (default "name") + timefmt string (default "Mon Jan _2 15:04:05 2006") ratios string (default "1:2:3") The following variables are exported for shell commands. diff --git a/docstring.go b/docstring.go index f0b69db..9cf8c49 100644 --- a/docstring.go +++ b/docstring.go @@ -49,9 +49,9 @@ The following commands are provided by lf without default keybindings. The following options can be used to customize the behavior of lf. + dirfirst bool (default on) hidden bool (default off) preview bool (default on) - dirfirst bool (default on) scrolloff int (default 0) tabstop int (default 8) ifs string (default "") (not exported if empty) @@ -59,6 +59,7 @@ The following options can be used to customize the behavior of lf. shell string (default "$SHELL") showinfo string (default "none") sortby string (default "name") + timefmt string (default "Mon Jan _2 15:04:05 2006") ratios string (default "1:2:3") The following variables are exported for shell commands. diff --git a/eval.go b/eval.go index c671b96..9ce5210 100644 --- a/eval.go +++ b/eval.go @@ -11,6 +11,15 @@ import ( func (e *SetExpr) eval(app *App, args []string) { switch e.opt { + case "dirfirst": + gOpts.dirfirst = true + app.nav.renew(app.nav.height) + case "nodirfirst": + gOpts.dirfirst = false + app.nav.renew(app.nav.height) + case "dirfirst!": + gOpts.dirfirst = !gOpts.dirfirst + app.nav.renew(app.nav.height) case "hidden": gOpts.hidden = true app.nav.renew(app.nav.height) @@ -26,15 +35,6 @@ func (e *SetExpr) eval(app *App, args []string) { gOpts.preview = false case "preview!": gOpts.preview = !gOpts.preview - case "dirfirst": - gOpts.dirfirst = true - app.nav.renew(app.nav.height) - case "nodirfirst": - gOpts.dirfirst = false - app.nav.renew(app.nav.height) - case "dirfirst!": - gOpts.dirfirst = !gOpts.dirfirst - app.nav.renew(app.nav.height) case "scrolloff": n, err := strconv.Atoi(e.val) if err != nil { @@ -92,6 +92,8 @@ func (e *SetExpr) eval(app *App, args []string) { } gOpts.sortby = e.val app.nav.renew(app.nav.height) + case "timefmt": + gOpts.timefmt = e.val case "ratios": toks := strings.Split(e.val, ":") var rats []int diff --git a/opts.go b/opts.go index 90a2bfe..2fc0f0f 100644 --- a/opts.go +++ b/opts.go @@ -1,6 +1,9 @@ package main +import "time" + var gOpts struct { + dirfirst bool hidden bool preview bool scrolloff int @@ -10,13 +13,14 @@ var gOpts struct { shell string showinfo string sortby string - dirfirst bool + timefmt string ratios []int keys map[string]Expr cmds map[string]Expr } func init() { + gOpts.dirfirst = true gOpts.hidden = false gOpts.preview = true gOpts.scrolloff = 0 @@ -24,7 +28,7 @@ func init() { gOpts.shell = envShell gOpts.showinfo = "none" gOpts.sortby = "name" - gOpts.dirfirst = true + gOpts.timefmt = time.ANSIC gOpts.ratios = []int{1, 2, 3} gOpts.keys = make(map[string]Expr) diff --git a/ui.go b/ui.go index 575ff1d..5316523 100644 --- a/ui.go +++ b/ui.go @@ -13,7 +13,6 @@ import ( "strconv" "strings" "text/tabwriter" - "time" "unicode/utf8" "github.com/nsf/termbox-go" @@ -405,7 +404,7 @@ func (ui *UI) loadFile(nav *Nav) { return } - ui.message = fmt.Sprintf("%v %v %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(time.ANSIC)) + ui.message = fmt.Sprintf("%v %v %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt)) if !gOpts.preview { return