diff --git a/complete.go b/complete.go index bd4a0011..b65d3d66 100644 --- a/complete.go +++ b/complete.go @@ -95,6 +95,7 @@ var ( "timefmt", "ratios", "info", + "shellopts", } ) diff --git a/doc.go b/doc.go index 358af8fb..ee56ab54 100644 --- a/doc.go +++ b/doc.go @@ -104,6 +104,7 @@ The following options can be used to customize the behavior of lf: timefmt string (default 'Mon Jan _2 15:04:05 2006') ratios string (default '1:2:3') info string (default '') + shellopts string (default '') The following variables are exported for shell commands: diff --git a/docstring.go b/docstring.go index 4102a08e..01c1cb7c 100644 --- a/docstring.go +++ b/docstring.go @@ -108,6 +108,7 @@ The following options can be used to customize the behavior of lf: timefmt string (default 'Mon Jan _2 15:04:05 2006') ratios string (default '1:2:3') info string (default '') + shellopts string (default '') The following variables are exported for shell commands: diff --git a/eval.go b/eval.go index 8fff73e5..01a69b8c 100644 --- a/eval.go +++ b/eval.go @@ -202,6 +202,8 @@ func (e *setExpr) eval(app *app, args []string) { } } gOpts.info = toks + case "shellopts": + gOpts.shellopts = strings.Split(e.val, ":") default: app.ui.printf("unknown option: %s", e.opt) } diff --git a/opts.go b/opts.go index 6dd582ac..7aadb627 100644 --- a/opts.go +++ b/opts.go @@ -43,6 +43,7 @@ var gOpts struct { timefmt string ratios []int info []string + shellopts []string keys map[string]expr cmdkeys map[string]expr cmds map[string]expr @@ -66,6 +67,7 @@ func init() { gOpts.timefmt = time.ANSIC gOpts.ratios = []int{1, 2, 3} gOpts.info = nil + gOpts.shellopts = nil gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.keys = make(map[string]expr) diff --git a/os.go b/os.go index 681e7ef7..3d59c731 100644 --- a/os.go +++ b/os.go @@ -65,6 +65,8 @@ func shellCommand(s string, args []string) *exec.Cmd { args = append([]string{"-c", s, "--"}, args...) + args = append(gOpts.shellopts, args...) + return exec.Command(gOpts.shell, args...) } diff --git a/os_windows.go b/os_windows.go index 09e9dace..565bff9d 100644 --- a/os_windows.go +++ b/os_windows.go @@ -39,6 +39,9 @@ func pauseCommand() *exec.Cmd { func shellCommand(s string, args []string) *exec.Cmd { args = append([]string{"/c", s}, args...) + + args = append(gOpts.shellopts, args...) + return exec.Command(gOpts.shell, args...) }