Skip to content

Instantly share code, notes, and snippets.

@realpdm
Created March 19, 2015 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realpdm/3e74ba93a04fc4379c8f to your computer and use it in GitHub Desktop.
Save realpdm/3e74ba93a04fc4379c8f to your computer and use it in GitHub Desktop.
Making tmux find ssh agent on reattach
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
}
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