Background: An co-worker at my company uses tmux all the time. In our spare-time he taught me enough to master tmux and vim. I have really falled in love with the power of this combination.

Currently, I am mainly using tmux in OS X, when I start the Terminal app. Depending where I go, I choose a different laptop (therefore other OS'es too) and so I often code via ssh remotely with my server running Ubuntu (Server version) where everything is at its place.

Problem: I'd like to connect to my server and instantly have the last tmux session available and never have the need to use the classic bash.

I currently solve it by having tmux new-session -A -s main in my rc config and using twice CTRL-D although I still fall back when I exit.

Is there a better way of doing this?

  • What about chsh?
    – o11c
    Jul 16, 2015 at 21:47

2 Answers 2


You don't want to overwrite your bash. You want tmux only for interactive sessions and you don't want to do it recursively like in the other answer.

Simple example taken from [1], with common use case where you try to attach last session, which can be useful. This should go into your ~/.bashrc.

echo Checking for tmux
if [ -z ${TMUX} ]; then
  /usr/bin/tmux attach || /usr/bin/tmux

[1] http://ubuntuforums.org/showthread.php?t=2236875


Are you speaking of launching tmux from your bash configuration file?

In that case, you should launch tmux by preceding it by the keyword exec:

exec tmux ...

in order to have bash being fully replaced by tmux.

You must log in to answer this question.