Skip to content

Instantly share code, notes, and snippets.

@sandipb sandipb/.bashrc
Last active Oct 11, 2018

Embed
What would you like to do?
Bashrc to keep a consistent tmux ssh-agent environment
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
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
You can’t perform that action at this time.