-
-
Save rctay/5886131 to your computer and use it in GitHub Desktop.
tmux: update current shell's environment's ssh agent forwarding info (ie. value of $SSH_AUTH_SOCK) when reconnecting, eg via PuTTY
This file contains hidden or 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
# next try: `test` before `export` | |
val=`tmux show-environment | grep '^SSH_AUTH_SOCK='`;\ | |
test -n "$val" && export "$val" | |
# with the $_ bash-ism: | |
test -n `tmux show-environment | grep '^SSH_AUTH_SOCK='`\ | |
&& export "$_"; |
This file contains hidden or 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
# use grep instead of `tmux showenv VAR` since output could possibly begin with | |
# '-' (for variables removed from environment) | |
eval `tmux show-environment | grep '^SSH_AUTH_SOCK='`; \ | |
export SSH_AUTH_SOCK | |
# as a function | |
function copy_one_tmux_env() { | |
eval `tmux show-environment | grep "^$1="` | |
export $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eval $(tmux showenv -s SSH_AUTH_SOCK)
is simpler