Last active
October 11, 2018 22:31
-
-
Save sandipb/a28d3f0608b2a6f364e0c4e6da821839 to your computer and use it in GitHub Desktop.
Bashrc to keep a consistent tmux ssh-agent environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOCK="/tmp/ssh-agent-$USER-screen" | |
SOCKPTR="$(readlink -f $SOCK 2> /dev/null)" | |
if [[ -z $SOCKPTR ]] || [[ ! -S $SOCKPTR ]] | |
then | |
echo -e "\e[31m\e[1mNo valid current tmux ssh-agent link\e[0m" | |
if [[ -n $SSH_AUTH_SOCK ]] && [[ -S $SSH_AUTH_SOCK ]] | |
then | |
rm -f $SOCK | |
ln -nsf $SSH_AUTH_SOCK $SOCK | |
# export SSH_AUTH_SOCK=$SOCK | |
echo -e "\e[32m\e[1mSet tmux ssh-agent link to $SSH_AUTH_SOCK \e[0m" | |
fi | |
else | |
echo -e "\e[32m\e[1m Not changing tmux ssh-agent link. Already set to valid $SOCKPTR \e[0m" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set-environment -g SSH_AUTH_SOCK /tmp/ssh-agent-$USER-screen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment