Skip to content

Instantly share code, notes, and snippets.

@von
Created January 16, 2015 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save von/4f88275aea50c4b33d10 to your computer and use it in GitHub Desktop.
Save von/4f88275aea50c4b33d10 to your computer and use it in GitHub Desktop.
" Prevent various Vim features from keeping the contents of pass(1) password
" files (or any other purely temporary files) in plaintext on the system.
"
" Modified from:
" Author: Tom Ryder <tom@sanctum.geek.nz>
" From: https://gist.github.com/tejr/5890634
"
" The '/private' part is Mac-specific
let s:passtmp='/private' . expand('$TMPDIR') . "pass.*/*"
" Don't backup files in temp directories or shm
if exists('&backupskip')
let &backupskip = &backupskip . ',' . s:passtmp
endif
" Don't keep swap files in temp directories or shm
if has('autocmd')
augroup swapskip
autocmd!
silent! autocmd BufNewFile,BufReadPre
\ s:passtmp
\ 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
\ s:passtmp
\ 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
\ s:passtmp
\ setlocal viminfo=
augroup END
endif
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment