]> git.wh0rd.org - home.git/blobdiff - .profile.d/keychain.sh
cros-board: update
[home.git] / .profile.d / keychain.sh
index 14a6289858052dfeee897fe159f1ab9ded37fd3b..c5ceb78f29c775263352e8c1fb955db75df96fee 100644 (file)
@@ -1,9 +1,16 @@
 # If an auth sock is already set & available, use it.
 # This way ssh agent forwarding still works.
-if [ ! -S "${SSH_AUTH_SOCK}" ] ; then
-       if type keychain >/dev/null 2>&1 ; then
+if type keychain >/dev/null 2>&1 ; then
+       if [ ! -S "${SSH_AUTH_SOCK}" ] ; then
                : ${HOSTNAME:=$(hostname)}
                [ -e ~/.keychain/${HOSTNAME}-sh ] && . ~/.keychain/${HOSTNAME}-sh
+       fi
+       if [ -z "${GPG_AGENT_INFO}" ] ; then
+               : ${HOSTNAME:=$(hostname)}
                [ -e ~/.keychain/${HOSTNAME}-sh-gpg ] && . ~/.keychain/${HOSTNAME}-sh-gpg
        fi
 fi
+
+# The agent might try to spawn pinentry on the tty it started
+# on instead of the tty gpg is now running on.
+export GPG_TTY="$(tty)"