Skip to content

Commit 2fc45dc

Browse files
lambdalisueLanius
andauthored
Add g:suda#nopass to skip password prompt (#53)
* nopass option * nopass option in README * nopass: suggested fixes * suda#nopass variable fix * nopass: add variable to the docs * Fix docs * Apply lexical order Co-authored-by: Lanius <laniuspne@pm.me>
1 parent 6bffe36 commit 2fc45dc

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ Make sure that the following shows `1`.
6969
```vim
7070
: echo executable('sudo')
7171
```
72+
73+
### Use sudo without a password
74+
75+
When `let g:suda#nopass = 1` is written in your vimrc, suda won't ask you for a password. Use at your own risk.

autoload/suda.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function! suda#system(cmd, ...) abort
2-
let cmd = has('win32')
2+
let cmd = has('win32') || g:suda#nopass
33
\ ? printf('sudo %s', a:cmd)
44
\ : printf('sudo -p '''' -n %s', a:cmd)
55
if &verbose
@@ -263,4 +263,5 @@ augroup suda_internal
263263
augroup END
264264

265265
" Configure
266+
let g:suda#nopass = get(g:, 'suda#nopass', 0)
266267
let g:suda#prompt = get(g:, 'suda#prompt', 'Password: ')

doc/suda.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ suda#write({expr} [, {options}])
160160
-----------------------------------------------------------------------------
161161
VARIABLE *suda-interface-variable*
162162

163+
*g:suda#nopass*
164+
If set, suda will not prompt you for a password before saving a file.
165+
It is suppossed to support a setup with passwordless sudo or doas.
166+
Use with care.
167+
Default: 0
168+
163169
*g:suda#prompt*
164170
A prompt string used to ask password.
165171
Default: "Password: "

0 commit comments

Comments
 (0)