Skip to content

Instantly share code, notes, and snippets.

@jathanism
Created March 8, 2019 17:30
Show Gist options
  • Select an option

  • Save jathanism/345209c4083eefe00a3b4a5d6512908a to your computer and use it in GitHub Desktop.

Select an option

Save jathanism/345209c4083eefe00a3b4a5d6512908a to your computer and use it in GitHub Desktop.
My tmux setup that keeps sessions working perfectly. Every time a new session is started and `tmux` is ran, `_ssh_auth_save()` is called to refresh the symlink to `SSH_AUTH_SOCK`.
# Put me in ~/.tmux.conf
set -g default-terminal "screen-256color"
set -g update-environment -r
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
# Put me in ~/.zshrc.local
# Link the latest ssh-agent socket
_ssh_auth_save() {
ln -sf $(find /tmp -maxdepth 2 -type s -name "agent*" -user $(whoami) -printf '%T@ %p\n' 2>/dev/null |sort -n|tail -1|cut -d' ' -f2) ~/.ssh/ssh_auth_sock
}
alias tmux='_ssh_auth_save ; tmux'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment