Wrap gpg snippet to ensure that the command is available

master
nirenjan 2020-09-09 07:49:26 -07:00
parent 9da5e26220
commit a866ab7d4e
1 changed files with 11 additions and 8 deletions

View File

@ -1,10 +1,13 @@
gpgconf --launch gpg-agent
export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
TSOCK=$(gpgconf --list-dirs agent-ssh-socket || true)
if [[ -n "$TSOCK" ]]
if command -v gpgconf >/dev/null
then
export SSH_AUTH_SOCK="$TSOCK"
unset TSOCK
gpgconf --launch gpg-agent
export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
TSOCK=$(gpgconf --list-dirs agent-ssh-socket || true)
if [[ -n "$TSOCK" ]]
then
export SSH_AUTH_SOCK="$TSOCK"
unset TSOCK
fi
fi