diff --git a/Makefile b/Makefile index 83af856..779e0a9 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/functions/vim_askpass_helper b/functions/vim_askpass_helper new file mode 100755 index 0000000..a530c4d --- /dev/null +++ b/functions/vim_askpass_helper @@ -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 diff --git a/sub/vim/vimrc b/sub/vim/vimrc index e136565..a241069 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -282,3 +282,8 @@ nnoremap qa :qa! " expand %% to dirname of cur file in commandline cnoremap %% 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'