Added option to automatically save files with sucmd

This commit is contained in:
prez
2019-09-11 15:35:41 +02:00
parent 3a8898dadd
commit aae0f4630e
3 changed files with 11 additions and 1 deletions

View File

@@ -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 {

View File

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