Skip to content

Instantly share code, notes, and snippets.

@MarcoMatarazzo
Forked from admackin/.bashrc
Last active August 29, 2015 14:24
Show Gist options
  • Save MarcoMatarazzo/25c2b9837211ea66e864 to your computer and use it in GitHub Desktop.
Save MarcoMatarazzo/25c2b9837211ea66e864 to your computer and use it in GitHub Desktop.
Sane SSH_AUTH_SOCK handling for Screen and Tmux, so that new SSH agents
created by subsequent logons are still usable.
_ssh_auth_save() {
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh-auth-sock.$HOSTNAME"
}
alias screen='_ssh_auth_save ; export HOSTNAME=$(hostname) ; screen'
alias tmux='_ssh_auth_save ; export HOSTNAME=$(hostname) ; tmux'
unsetenv SSH_AUTH_SOCK
setenv SSH_AUTH_SOCK $HOME/.ssh/ssh-auth-sock.$HOSTNAME
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
set-environment -g SSH_AUTH_SOCK $HOME/.ssh/ssh-auth-sock.$HOSTNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment