diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index 83eec144..761ae51b 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -994,7 +994,12 @@ func (v *View) saveToFile(filename string) { err := v.Buf.SaveAs(filename) if err != nil { if strings.HasSuffix(err.Error(), "permission denied") { - choice, _ := messenger.YesNoPrompt("Permission denied. Do you want to save this file using sudo? (y,n)") + var choice bool + if globalSettings["autosu"].(bool) { + choice = true + } else { + choice, _ = messenger.YesNoPrompt("Permission denied. Do you want to save this file using sudo? (y,n)") + } if choice { err = v.Buf.SaveAsWithSudo(filename) if err != nil { diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index c8e50e12..dcae0ef5 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -236,6 +236,7 @@ func DefaultGlobalSettings() map[string]interface{} { "splitright": true, "statusline": true, "sucmd": "sudo", + "autosu": false, "syntax": true, "tabmovement": false, "tabsize": float64(4), diff --git a/runtime/help/options.md b/runtime/help/options.md index 0a85d4ae..679a1ab6 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -210,6 +210,10 @@ Here are the options that you can set: default value: `sudo` +* `autosu`: defines whether super user saving should be used automatically. + + default value: `false` + * `tabmovement`: navigate spaces at the beginning of lines as if they are tabs (e.g. move over 4 spaces at once). This option only does anything if `tabstospaces` is on.