Vimscript to Read/Write Keybase's Saltpack encrypted files

2 Points

Jeff Jeff

11 months ago

Very basic file type handler for Keybase's Saltpack. It assumes you are logged in and the command line interface is in your path.

" Keybase - saltpack
augroup SALTPACK
  " Make sure nothing is written to ~/.viminfo
  au BufReadPre,FileReadPre *.saltpack set viminfo=
  " No other files with unencrypted info
  au BufReadPre,FileReadPre *.saltpack set noswapfile noundofile nobackup

  " Reading Files, assumes you can decrypt
  au BufReadPost,FileReadPost *.saltpack :%!keybase decrypt

  " Writing requires users
  au BufWritePre,FileReadPre *.saltpack let usernames = input('Users: ')
  au BufWritePre,FileReadPre *.saltpack :exec "%!keybase encrypt " . usernames
  au BufWritePost,FileReadPost *.saltpack u
augroup END