Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A shell command to refresh SSH_AUTH_SOCK in a running tmux session
r () {
if [[ -n $TMUX ]]
then
NEW_SSH_AUTH_SOCK=`tmux showenv|grep "^SSH_AUTH_SOCK"|cut -d = -f 2`
if [[ -n $NEW_SSH_AUTH_SOCK ]] && [[ -S $NEW_SSH_AUTH_SOCK ]]
then
echo "New auth sock: $NEW_SSH_AUTH_SOCK"
SSH_AUTH_SOCK=$NEW_SSH_AUTH_SOCK
fi
NEW_DISPLAY=`tmux showenv|grep "^DISPLAY"|cut -d = -f 2`
if [[ -n $NEW_DISPLAY ]]
then
echo "New display: $NEW_DISPLAY"
DISPLAY=$NEW_DISPLAY
fi
fi
}
@matsen

This comment has been minimized.

Copy link
Owner Author

@matsen matsen commented Jan 3, 2020

I got this from @cmccoy and couldn't find it anywhere else so pasted it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment