powgbg
Last Updated: February 25, 2016
·
7.349K
· teamon
9fae8c5d475fe322a3a74e53d56ee2a0

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.

Say Thanks
Respond

2 Responses
Add your response

15761
72be72598fe18da3ea9e5e98bc515f14

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
Snoopy

@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 ·
Filed Under