From e36d1afffa8844f82a83c9a0632ae9d4211d6a3c Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 27 Mar 2021 12:14:43 +0000 Subject: [PATCH] zshrc: Work around gnupg agent path on Fedora Fedora seems to put it in $XDG_RUNTIME_DIR/gnupg/. Check if $XDG_RUNTIME_DIR/gnupg exists and pick the first socket we find in there (there should only be one). --- zshrc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zshrc b/zshrc index 1838ea3..06b6960 100644 --- a/zshrc +++ b/zshrc @@ -345,9 +345,16 @@ __has_command url2pkg && __has_command mpv && alias mpv="LC_ALL=C mpv" if __has_command gpg gpg2; then - alias gssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh" - alias gssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add" - alias gsftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp" + local sock + if [ -d "$XDG_RUNTIME_DIR/gnupg" ]; then + sock=$(find $XDG_RUNTIME_DIR/gnupg -name S.gpg-agent.ssh | + head -1) + fi + [ -n "$sock" ] || sock="$GNUPGHOME/S.gpg-agent.ssh" + + alias gssh="SSH_AUTH_SOCK=$sock ssh" + alias gssh-add="SSH_AUTH_SOCK=$sock ssh-add" + alias gsftp="SSH_AUTH_SOCK=$sock sftp" fi if __has_command cryptopassphrase; then