From 0dfd7d0e8bbd638b473c95aed6c7315532466340 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Mon, 19 Nov 2018 18:14:36 +1100 Subject: [PATCH] bash: improve SSH_AUTH_SOCK detection --- .bashrc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.bashrc b/.bashrc index bd58678..8f6421a 100644 --- a/.bashrc +++ b/.bashrc @@ -1,3 +1,5 @@ +# shellcheck disable=SC1090 # -- Can't follow non-constant source + ########################### # 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 - # shellcheck disable=SC1090 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 - 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 -- 2.39.2