From 2b5f43668cf476ff8d04506b9dd9e38b53619979 Mon Sep 17 00:00:00 2001 From: Keanu Date: Mon, 10 May 2021 17:05:55 +0200 Subject: [PATCH] [zsh] Add gpg-crypt commands --- zsh/functions.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index a9d956d..b3cf23a 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -102,3 +102,25 @@ sudoedit() { } alias sudoe="sudoedit" alias sue="sudoedit" + +# gpg-crypt {{{ + # Encrypt the given file or directory to a given recipient + function gpg-encrypt() { + if [ "$#" -ne 2 ]; then + echo "Usage: $0 FILE/DIRECTORY RECIPIENT" >&2 + return 1 + fi + + tar -c `basename $1` | gpg --encrypt --recipient $2 -o `basename $1`.tar.gpg + } + + # Decrypt the given tar.gpg file + function gpg-decrypt() { + if [ "$#" -ne 1 ] || [[ "$1" != *.tar.gpg ]]; then + echo "Usage: $0 FILE.tar.gpg" >&2 + return 1 + fi + + gpg --quiet --decrypt $1 | tar -x + } +# }}}