Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My current workflow is:

  1. CTRL+SHIFT+T to launch a new terminal window. That starts a new zsh terminal.
  2. Type tmux to start tmux.

How can I have tmux load by default with a new terminal window?

share|improve this question
up vote 17 down vote accepted

There are at least two ways:

  1. Write something like

    if [ "$TMUX" = "" ]; then tmux; fi

    at the beginning of ~/.zshrc. Note the conditional test to a possible loop when tmux spawns its own zsh.

  2. Modify terminal launching command to something like

    xterm -e tmux

I prefer the second way, because sometimes I need to launch a terminal without tmux (for example when I need to reconnect to an existing session).

share|improve this answer
Or have different shortcuts for xterm -e tmux and plain xterm. – Nikolai N Fetissov Jun 21 '12 at 13:37
Yes, actually I meant it under "I prefer the second way" =) – rush Jun 21 '12 at 13:39
Executing tmux at the end of .zshrc will cause an endless loop of zsh starting tmux starting zsh starting tmux ... – Thor Jun 21 '12 at 14:56
How would one go about "modifying terminal launching command"? – eoinoc Jun 22 '12 at 9:04
@eoinoc it depends on your environment. For example, I'm using awesome wm, therefore I just need to modify string in my config file. In kde you need to edit hotkeys. And so on. – rush Jun 22 '12 at 9:11

Be careful with the echo tmux >> ~/.zshrc solution though, I remember that simply throwing a bash in a .cshrc file caused me trouble over SSH.

IIRC the problem occurred with non-interactive shells, so you should test for that.

case $- in *i*)
  if [ -z "$TMUX" ]; then exec tmux; fi;;
share|improve this answer
You're missing a space between " and ]. – n.st Apr 9 '14 at 1:17

Add "tmux" to your .zshrc file, which gets executed every time you start zsh. The quick way:

echo tmux >> ~/.zshrc
share|improve this answer

Your Answer


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.