From: James Bunton Date: Mon, 19 Nov 2018 07:14:36 +0000 (+1100) Subject: bash: improve SSH_AUTH_SOCK detection X-Git-Url: https://code.delx.au/dotfiles/commitdiff_plain/0dfd7d0e8bbd638b473c95aed6c7315532466340 bash: improve SSH_AUTH_SOCK detection --- 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