Announcement

Collapse
No announcement yet.

Seamless gpg/vim integration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Seamless gpg/vim integration

    Ran into this the other day and thought it was infinitely badass... a little block you can add to your .vimrc to let you seamlessly edit .gpg files:

    Code:
    augroup encrypted
    au!
    autocmd BufReadPre,FileReadPre *.gpg,*.asc set viminfo=
    autocmd BufReadPre,FileReadPre *.gpg,*.asc set noswapfile
    autocmd BufReadPre,FileReadPre *.gpg set bin
    autocmd BufReadPre,FileReadPre *.gpg,*.asc let ch_save = &ch|set ch=2
    
    autocmd BufReadPost,FileReadPost *.gpg,*.asc '[,']!sh -c 'gpg --decrypt 2> /dev/
    null'
    autocmd BufReadPost,FileReadPost *.gpg set nobin
    autocmd BufReadPost,FileReadPost *.gpg,*.asc let &ch = ch_save|unlet ch_save
    autocmd BufReadPost,FileReadPost *.gpg,*.asc execute ":doautocmd BufReadPost " .
     expand("%:r")
    
    autocmd BufWritePre,FileWritePre *.gpg '[,']!sh -c 'gpg --default-recipient-self
     -e 2>/dev/null'
    autocmd BufWritePre,FileWritePre *.asc '[,']!sh -c 'gpg --default-recipient-self
     -e -a 2>/dev/null'
    
    autocmd BufWritePost,FileWritePost *.gpg,*.asc u
    augroup END
    45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B0
    45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B1
    [ redacted ]
Working...
X