From f580c00446756577f5595c595de55f274a57a169 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Wed, 6 Mar 2024 00:51:48 +1100 Subject: [PATCH] bashrc: SSH_AUTH_SOCK improvements --- .bashrc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.bashrc b/.bashrc index d75f6ea..300ab1d 100644 --- 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" -- 2.39.2