]> code.delx.au - dotfiles/commitdiff
bash: improve SSH_AUTH_SOCK detection
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 19 Nov 2018 07:14:36 +0000 (18:14 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 19 Nov 2018 07:15:01 +0000 (18:15 +1100)
.bashrc

diff --git a/.bashrc b/.bashrc
index bd586785cad1e68b82a4d9e8da03600f7fbe5971..8f6421ac0e86d8e48d9f638a3256242d47b945e2 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -1,3 +1,5 @@
+# shellcheck disable=SC1090 # -- Can't follow non-constant source
+
 ###########################
 # Settings for all shells #
 ###########################
 ###########################
 # Settings for all shells #
 ###########################
@@ -16,15 +18,18 @@ done < <(find ~/bin -type d 2> /dev/null)
 
 # Set EMAIL from the freedesktop environment.d
 if [ -r ~/.config/environment.d/10-email.conf ]; then
 
 # Set EMAIL from the freedesktop environment.d
 if [ -r ~/.config/environment.d/10-email.conf ]; then
-    # shellcheck disable=SC1090
     source ~/.config/environment.d/10-email.conf
     export EMAIL
 fi
 
     source ~/.config/environment.d/10-email.conf
     export EMAIL
 fi
 
-# Pick up SSH agent socket in case it isn't set automatically
+# Pick up SSH agent socket
 if [ -z "$SSH_AUTH_SOCK" ]; then
 if [ -z "$SSH_AUTH_SOCK" ]; then
-    SSH_AUTH_SOCK="/run/user/$(id -u)/keyring/ssh"
-    export SSH_AUTH_SOCK
+    if [ -r ~/.ssh-agent.env ]; then
+        source ~/.ssh-agent.env
+    else
+        SSH_AUTH_SOCK="/run/user/$(id -u)/keyring/ssh"
+        export SSH_AUTH_SOCK
+    fi
 fi
 
 
 fi