diff --git a/app.go b/app.go index d627171..6f81a93 100644 --- a/app.go +++ b/app.go @@ -16,7 +16,7 @@ type App struct { func waitKey() error { // TODO: this should be done with termbox somehow - cmd := exec.Command(envShell, "-c", "echo; echo -n 'Press any key to continue'; stty -echo; read -n 1; stty echo; echo") + cmd := exec.Command(gOpts.shell, "-c", "echo; echo -n 'Press any key to continue'; stty -echo; read -n 1; stty echo; echo") cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout @@ -98,7 +98,7 @@ func (app *App) runShell(s string, args []string, wait bool, async bool) { } args = append([]string{"-c", s, "--"}, args...) - cmd := exec.Command(envShell, args...) + cmd := exec.Command(gOpts.shell, args...) if !async { cmd.Stdin = os.Stdin diff --git a/comp.go b/comp.go index da13c3f..86e387e 100644 --- a/comp.go +++ b/comp.go @@ -11,16 +11,18 @@ import ( var ( gCmdWords = []string{"set", "map", "cmd"} gOptWords = []string{ - "preview", - "nopreview", - "preview!", "hidden", "nohidden", "hidden!", - "tabstop", + "preview", + "nopreview", + "preview!", "scrolloff", - "sortby", + "tabstop", + "ifs", + "shell", "showinfo", + "sortby", "ratios", } ) diff --git a/doc/reference.md b/doc/reference.md index bb479f9..4f4fca5 100644 --- a/doc/reference.md +++ b/doc/reference.md @@ -23,12 +23,14 @@ ## Options - preview bool (default on) hidden bool (default off) - tabstop int (default 8) + preview bool (default on) scrolloff int (default 0) - sortby string (default name) + tabstop int (default 8) + ifs string (default not set) + shell string (default $SHELL) showinfo string (default none) + sortby string (default name) ratios string (default 1:2:3) ## Variables diff --git a/etc/lfrc.example b/etc/lfrc.example index d870be9..ec34dd9 100644 --- a/etc/lfrc.example +++ b/etc/lfrc.example @@ -5,6 +5,13 @@ #set nopreview #set showinfo size +# Some systems use more efficient shell implementations for non-interactive use +# (e.g. `dash`) mapped to `/bin/sh`. By setting this option here we can tell +# `lf` to use this implementation for shell commands. This can decrease the +# startup times of commands but may also change the syntax that you are used to +# (e.g. non-POSIX features provided by your regular shell). +set shell /bin/sh + # leave some space at the top and the bottom of the screen set scrolloff 10 diff --git a/eval.go b/eval.go index 41e4479..cf1bca2 100644 --- a/eval.go +++ b/eval.go @@ -62,6 +62,8 @@ func (e *SetExpr) eval(app *App, args []string) { gOpts.tabstop = n case "ifs": gOpts.ifs = e.val + case "shell": + gOpts.shell = e.val case "showinfo": if e.val != "none" && e.val != "size" && e.val != "time" { msg := "showinfo should either be 'none', 'size' or 'time'" diff --git a/opts.go b/opts.go index e9fe79b..2207cb6 100644 --- a/opts.go +++ b/opts.go @@ -6,6 +6,7 @@ type Opts struct { scrolloff int tabstop int ifs string + shell string showinfo string sortby string ratios []int @@ -21,6 +22,7 @@ func init() { gOpts.scrolloff = 0 gOpts.tabstop = 8 gOpts.ifs = "" + gOpts.shell = envShell gOpts.showinfo = "none" gOpts.sortby = "name" gOpts.ratios = []int{1, 2, 3}