Add sucmd to customize "sudo" command

Fixes #833
This commit is contained in:
Zachary Yedidia
2017-10-01 21:55:43 -04:00
parent 46ced988eb
commit f4e94d6d34
5 changed files with 18 additions and 5 deletions

View File

@@ -181,6 +181,13 @@ func OptionValueComplete(inputOpt, input string) (string, []string) {
if strings.HasPrefix("dos", input) {
suggestions = append(suggestions, "dos")
}
case "sucmd":
if strings.HasPrefix("sudo", input) {
suggestions = append(suggestions, "sudo")
}
if strings.HasPrefix("doas", input) {
suggestions = append(suggestions, "doas")
}
}
}

View File

@@ -431,7 +431,7 @@ func (b *Buffer) SaveAsWithSudo(filename string) error {
screen = nil
// Set up everything for the command
cmd := exec.Command("sudo", "tee", filename)
cmd := exec.Command(b.Settings["sucmd"].(string), "tee", filename)
cmd.Stdin = bytes.NewBufferString(b.SaveString(b.Settings["fileformat"] == "dos"))
// This is a trap for Ctrl-C so that it doesn't kill micro

File diff suppressed because one or more lines are too long

View File

@@ -215,6 +215,7 @@ func DefaultGlobalSettings() map[string]interface{} {
"splitRight": true,
"splitBottom": true,
"statusline": true,
"sucmd": "sudo",
"syntax": true,
"tabmovement": false,
"tabsize": float64(4),

View File

@@ -177,6 +177,11 @@ Here are the options that you can set:
default value: `on`
* `sucmd`: specifies the super user command. On most systems this is "sudo" but on BSD it can be "doas." This
option can be customized and is only used when saving with su.
default value: `sudo`
---
Default plugin options: