Skip to content

Instantly share code, notes, and snippets.

@matsen
Created January 3, 2020 14:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsen/b121999f861cd001c6814a20d032fa53 to your computer and use it in GitHub Desktop.
Save matsen/b121999f861cd001c6814a20d032fa53 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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