From a866ab7d4e10b2c2923246d52ff3af61d4c2c6df Mon Sep 17 00:00:00 2001 From: nirenjan Date: Wed, 9 Sep 2020 07:49:26 -0700 Subject: [PATCH] Wrap gpg snippet to ensure that the command is available --- zsh/gpg.zsh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/zsh/gpg.zsh b/zsh/gpg.zsh index 0a4b664..47c928b 100644 --- a/zsh/gpg.zsh +++ b/zsh/gpg.zsh @@ -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