Skip to content

Instantly share code, notes, and snippets.



Created Mar 4, 2016
What would you like to do?
edit GPG-encrypted files reasonably
set -e
usage() {
local s="$(basename "$0")"
echo "usage: $s [identity] [file]"
echo " ie: $s ~/some-secret-file.asc"
identity="$1"; shift || { usage >&2; exit 1; }
filename="$1"; shift || { usage >&2; exit 1; }
trap "( set -x; shred -zu '$tmp' )" EXIT
if [ -s "$filename" ]; then
( set -x; gpg --decrypt --output "$tmp" --yes "$filename" )
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.