add an option to configure shell used by commands
This commit is contained in:
parent
4dc8eccf9e
commit
ce25fc55ca
4
app.go
4
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
|
||||
|
12
comp.go
12
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",
|
||||
}
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
2
eval.go
2
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'"
|
||||
|
2
opts.go
2
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}
|
||||
|
Loading…
Reference in New Issue
Block a user