Skip to content

Instantly share code, notes, and snippets.

@AuHau
Created November 17, 2021 10:49
Show Gist options
  • Save AuHau/802182c6c9b4b472d49dcc04a940e1fa to your computer and use it in GitHub Desktop.
Save AuHau/802182c6c9b4b472d49dcc04a940e1fa to your computer and use it in GitHub Desktop.
GPG encryption for all primary's keys subkeys
function gpg-encrypt-me
if not set -q GPG_ME
echo "No your's GPG key set in GPG_ME variable!"
end
set recipients (gpg --list-keys --with-colons --fast-list-mode $GPG_ME | awk -F: '/^sub/{if ($12 == "e") {printf "-r 0x%s! ", $5}}')
gpg -r $recipients --armor --encrypt $argv
end
@AuHau
Copy link
Author

AuHau commented Nov 17, 2021

If you have multiple encryption subkeys (like for example me, who has around 3 YubiKeys and for each dedicated Subkey set), then GPG does not by default encrypts for all of them. This is a simple fish function that encrypts for all your subkeys defined by the primary key specified in GPG_ME variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment