Skip to content

Instantly share code, notes, and snippets.

@jimpsson
Last active October 28, 2019 18:57
Show Gist options
  • Save jimpsson/2f48c1725f2443b6360d2af18e3dfe58 to your computer and use it in GitHub Desktop.
Save jimpsson/2f48c1725f2443b6360d2af18e3dfe58 to your computer and use it in GitHub Desktop.
Initialize GnuPG and gpg-agent with Yubikey from the startup of Zsh
# pre-init.zsh
# 2019-10-28
# @JKL9x
# ~/.gnupg doesn't exists
if [[ ! -d $HOME/.gnupg ]]; then
print -Pn "%K{1}%F{230}Stow gnupg or SSH/GPG will no work fully.%f%k"
else
# ~/.gnupg exists
# ~/.gnupg/S.gpg-agent doesn't exists and or isn't a socket
if [[ ! -S $HOME/.gnupg/S.gpg-agent ]]; then
echo "Not fine"
gpg -K
curl -L $GPG_PUBLIC_KEY_URL | gpg --import
else
echo "Everything seems fine!"
fi
fi
# vim: set ft=zsh sw=2:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment