dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit f760d3e97828619b3fabb0996dbd88bc037f4339
parent 480cf815547ace87e227cfc764770ea1faddbf1a
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 29 Dec 2017 22:48:01 -0500

Smarter SSH agent initialization

Diffstat:
M.bashrc | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -37,13 +37,19 @@ fi # Configure GPG as an SSH key provider export GPG_TTY=$(tty) +gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 unset SSH_AGENT_PID -if [[ -S $HOME/.gnupg/S.gpg-agent.ssh ]] -then - export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh -elif [[ -S /run/user/$UID/gnupg/S.gpg-agent.ssh ]] + +# Assume SSH agent is forward if we're in an SSH session +if [[ -z "$SSH_TTY" ]] then - export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh" + if [[ -S $HOME/.gnupg/S.gpg-agent.ssh ]] + then + export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh + elif [[ -S /run/user/$UID/gnupg/S.gpg-agent.ssh ]] + then + export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh" + fi fi # Git command line configuration