From f924746af684d44abe1fd67eb681ed10438819a8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 15 Jan 2015 10:49:12 +0100 Subject: Add tejr's script --- contrib/vim/noplaintext.vim | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 contrib/vim/noplaintext.vim (limited to 'contrib/vim') diff --git a/contrib/vim/noplaintext.vim b/contrib/vim/noplaintext.vim new file mode 100644 index 0000000..9493194 --- /dev/null +++ b/contrib/vim/noplaintext.vim @@ -0,0 +1,46 @@ +" +" Prevent various Vim features from keeping the contents of pass(1) password +" files (or any other purely temporary files) in plaintext on the system. +" +" Either append this to the end of your .vimrc, or install it as a plugin with +" a plugin manager like Tim Pope's Pathogen. +" +" Author: Tom Ryder +" + +" Don't backup files in temp directories or shm +if exists('&backupskip') + set backupskip+=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* +endif + +" Don't keep swap files in temp directories or shm +if has('autocmd') + augroup swapskip + autocmd! + silent! autocmd BufNewFile,BufReadPre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal noswapfile + augroup END +endif + +" Don't keep undo files in temp directories or shm +if has('persistent_undo') && has('autocmd') + augroup undoskip + autocmd! + silent! autocmd BufWritePre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal noundofile + augroup END +endif + +" Don't keep viminfo for files in temp directories or shm +if has('viminfo') + if has('autocmd') + augroup viminfoskip + autocmd! + silent! autocmd BufNewFile,BufReadPre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal viminfo= + augroup END + endif +endif -- cgit v1.2.3