vim: alias Sw to save by root

This commit is contained in:
TheK4n 2023-01-09 23:35:46 +03:00
parent b5d7b831c9
commit 5627bbb420
3 changed files with 8 additions and 0 deletions

View File

@ -44,6 +44,7 @@ vim:
ln -s $(PWD)/light/.vimrc ~/.vimrc
mkdir -p ~/.config/nvim/lua
ln -s ~/.vim/vimrc ~/.config/nvim/init.vim
ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin
ln -s $(PWD)/sub/vim/init.lua ~/.config/nvim/lua/init.lua
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
nvim +PluginInstall +qall

2
functions/vim_askpass_helper Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo -e "OPTION title=vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2

View File

@ -282,3 +282,8 @@ nnoremap <silent> <Leader>qa :qa!<CR>
" expand %% to dirname of cur file in commandline
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
# :Sw to save file by root
command Sw execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null'