powgbg
Last Updated: September 22, 2018
·
7.85K
· teamon

Always use tmux with ssh

Put this in your .zshrc/.bashrc

function ssht(){
  ssh $* -t 'tmux a || tmux || /bin/bash'
}

Now

$ ssht user@host

will attach to existing tmux session, create new if one does not exist or just start bash if there is no tmux available.

2 Responses
Add your response

15761

Love this tip, a small adjustment I made was to use the users default shell (where it isn't /bin/bash):

getent passwd $LOGNAME | cut -d: -f7

over 1 year ago ·
17444

@teamon and then you're just one step away from what I consider to be the ideal ssh+tmux setup: http://goo.gl/XumZS9

over 1 year ago ·