Created
January 3, 2020 14:42
-
-
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
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got this from @cmccoy and couldn't find it anywhere else so pasted it here.