map F8 to regenerate a password under the cursor using pwgen

master
Andrew Coleman 2020-12-07 08:16:35 -05:00
parent aefb81ced7
commit 979057da70
1 changed files with 9 additions and 0 deletions

9
.vimrc
View File

@ -145,4 +145,13 @@ if !has('gui_running')
set t_Co=256
endif
nnoremap <F8> :call SetNewPassword()<CR>
function! SetNewPassword()
let cur_word = expand('<cword>')
let cmd = 'pwgen ' . strlen(cur_word) . ' 1'
let new_password = system(cmd)[:-2]
" Replace current word with a new random password of the same length
call setline(line('.'), substitute(getline('.'), cur_word, new_password, ""))
endfunction
call plug#end()