Skip to content

Instantly share code, notes, and snippets.

@tianon

tianon/vim-gpg

Created Mar 4, 2016
Embed
What would you like to do?
edit GPG-encrypted files reasonably
#!/bin/bash
set -e
usage() {
local s="$(basename "$0")"
echo "usage: $s [identity] [file]"
echo " ie: $s jsmith@example.com ~/some-secret-file.asc"
}
identity="$1"; shift || { usage >&2; exit 1; }
filename="$1"; shift || { usage >&2; exit 1; }
tmp="$(mktemp)"
trap "( set -x; shred -zu '$tmp' )" EXIT
if [ -s "$filename" ]; then
( set -x; gpg --decrypt --output "$tmp" --yes "$filename" )
fi
vim "$tmp"
( set -x; gpg --encrypt --armor --recipient "$identity" --output "$filename" --yes "$tmp" )
# trap shreds $tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.