]> code.delx.au - dotfiles/commitdiff
bashrc: SSH_AUTH_SOCK improvements
authorJames Bunton <jamesbunton@delx.au>
Tue, 5 Mar 2024 13:51:48 +0000 (00:51 +1100)
committerJames Bunton <jamesbunton@delx.au>
Tue, 5 Mar 2024 13:51:48 +0000 (00:51 +1100)
.bashrc

diff --git a/.bashrc b/.bashrc
index d75f6eaf314cb07b1c1eb8d2807b8b1b03a520bb..300ab1dd8795c0c21d1053b2dd5f1c7532ae14d2 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -20,10 +20,16 @@ done < <(find -L ~/bin -depth -maxdepth 1 -type d 2> /dev/null)
 # Set environment variables, eg EMAIL, LANG
 eval "$(cat 2> /dev/null /etc/default/locale /etc/locale.conf ~/.config/environment.d/*.conf | awk -F= '/^[^# ]/ {print $0 ";export " $1}')"
 
+# Look for XDG_RUNTIME_DIR
+if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$(id -u)" ]; then
+    XDG_RUNTIME_DIR="/run/user/$(id -u)"
+    export XDG_RUNTIME_DIR
+fi
+
 # Pick up SSH agent socket
 if [ -z "$SSH_AUTH_SOCK" ]; then
-    for p in keyring/ssh openssh_agent; do
-        SSH_AUTH_SOCK="/run/user/$(id -u)/$p"
+    for p in keyring/ssh gcr/ssh openssh_agent; do
+        SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/$p"
         if [ -S "$SSH_AUTH_SOCK" ]; then
             export SSH_AUTH_SOCK
             break
@@ -31,12 +37,6 @@ if [ -z "$SSH_AUTH_SOCK" ]; then
     done
 fi
 
-# Look for XDG_RUNTIME_DIR
-if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$(id -u)" ]; then
-    XDG_RUNTIME_DIR="/run/user/$(id -u)"
-    export XDG_RUNTIME_DIR
-fi
-
 # Look for DBUS
 if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -S "/run/user/$(id -u)/bus" ]; then
     DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"