Created
March 19, 2015 18:14
-
-
Save realpdm/3e74ba93a04fc4379c8f to your computer and use it in GitHub Desktop.
Making tmux find ssh agent on reattach
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
fixssh() { | |
for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do | |
if (tmux show-environment | grep "^${key}" > /dev/null); then | |
value=`tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//"` | |
export ${key}="${value}" | |
fi | |
done | |
} |
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
preexec() { | |
if [[ -n $TMUX && ! -S "$SSH_AUTH_SOCK" ]]; then | |
fixssh | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment