map F8 to regenerate a password under the cursor using pwgen
parent
aefb81ced7
commit
979057da70
9
.vimrc
9
.vimrc
|
@ -145,4 +145,13 @@ if !has('gui_running')
|
||||||
set t_Co=256
|
set t_Co=256
|
||||||
endif
|
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()
|
call plug#end()
|
||||||
|
|
Reference in New Issue