1

I do want to use tmux by default when I am establshing ssh connection and this works well with a command like:

ssh host.example.com -t 'tmux a || tmux || /bin/bash'

I can even put this as part of the ProxyCommand inside the ~/.ssh/config but the problem is that I am also doing SSH connections as part of scripts that are just running different commands on the remote machines and I do not want tmux in this case.

How can I achieve this behaviour so tmux invocation would be transparent and happen only when ssh is colled without any paramerts / commands.

2 Answers 2

1

You're re-inventing the wheel.

  • Install Byobo.
  • byobu-enable
0

Solved by adding this to ~/.bashrc:

function ssh() {
  if [ "$#" == "1" ]; then
    if [ "${1:0:1}" != "-" ]; then
      /usr/bin/ssh "$@" -t 'tmux a || tmux || /bin/bash'
    else
    /usr/bin/ssh "$@";
    fi
  else
    /usr/bin/ssh "$@";
  fi
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .