Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Background: An co-worker at my company uses tmux all the time, in our spare-time he teached me mastering tmux and vim and I really fall 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 (therefor other OS'es too) and so I often code via ssh remotely with my server running Ubuntu (Server version) where everything is at it's place.

Problem: I'd like to connect to my server and instantly have the last tmux session avaiable and never having 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?

share|improve this question

migrated from stackoverflow.com Jul 17 at 14:45

This question came from our site for professional and enthusiast programmers.

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

2 Answers 2

up vote 3 down vote accepted

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
fi

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.