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.

I would like my default bash shell to go straight into tmux instead of my always having to type tmux every time.

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted

This seems to work...

https://wiki.archlinux.org/index.php/Tmux#Start_tmux_on_every_shell_login

Simply add the following line of bash code to your .bashrc before your aliases; the code for other shells is very similar:

[[ $TERM != "screen" ]] && exec tmux
share|improve this answer
3  
Please don't post answers that are just links to other pages; at least summarize what it says –  Michael Mrozek Jul 20 '12 at 17:32
    
For me this also required [[ $- != *i* ]] && return to not being an infinite loop (from the same page) –  Keith Smiley Apr 14 '13 at 1:45
add comment

@StarNamer's answer is generally accurate, though I typically include the following test to make sure tmux doesn't try to run within itself:

if test -z $TMUX && [[ $TERM != "screen" ]]; then
  exec tmux
fi
share|improve this answer
add comment

There is command chsh which changes login shell. Consult man chsh.

share|improve this answer
    
tmux is not a shell, it's a terminal multiplexer like GNU screen. Interestingly, it does support the -c option according to the man page, so it may work like a shell just enough to use it as your login shell, but I suspect it won't work properly in all situations, e.g. graphical logins via gdm/kdm. –  Mikel Jul 20 '12 at 15:32
add comment

As Mikel already stated in his comment to have tmux as your login shell can have side effects. But you can make tmux your default shell, literally. A user's default shell is defined in /etc/passwd. So you can become root and edit /etc/passwd, e.g. sudo vi /etc/passwd search for the line that begins with your username. It probably ends with :/bin/bash. Change /bin/bash to /usr/bin/tmux and now tmux is your default login shell.

However, no guarantee that this won't cause problems!

What may work better is to NOT do anything that requries root privileges. I would try to create a file in my home directoy named .bash_login and start tmux from within that file: `echo "tmux" >~/.bash_login.

This should work, but you have to try and find our yourself, b/c the bash documentation is not very exact about what file is read and executed when.

share|improve this answer
    
What your first paragraph describes is what chsh does! Except that your way requires being root and is error-prone. Running tmux from .bash_login is more likely to break remote logins. –  Gilles Jul 20 '12 at 23:10
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.