add 'shellopts' option to set shell arguments

Related #102
This commit is contained in:
Gokcehan committed 2018-06-26 21:14:55 +03:00
1 parent 4c54acebeb
commit e99478e8a1
7 files changed
+12

No files matched your search

+1
View File
@@ -95,6 +95,7 @@ var (
"timefmt",
"ratios",
"info",
"shellopts",
}
)
+1
View File
@@ -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:
+1
View File
@@ -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:
+2
View File
@@ -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)
}
+2
View File
@@ -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)
+2
View File
@@ -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...)
}
+3
View File
@@ -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...)
}