How to run zsh and tmux with xterm-256color by default

13,325

Solution 1

Usually tmux should get the TERM parameter from your terminal emulator. So you could just set it to xterm-256color in your its configuration.

If this does not work for some reason, you can start tmux like that

tmux -2

The parameter -2 forces tmux to assume 256-color support. Additionally you can set default-terminal in your `~/.tmux.conf

set -g default-terminal "screen-256color"

Solution 2

For proper installation, follow this order:

  1. Install zsh
  2. Run zsh from your terminal/bash
  3. Set zsh as default terminal/bash
  4. Setup tmux to run as default

After zsh is installed, run it from terminal

$ zsh

now set zsh as default Shell with

$ chsh -s /bin/zsh 

Note that you must be on zsh when typing this command (tested this on my Ubuntu 14.04.2 LTS - trusty)

SO, now you've setup the default Shell... All you have to do now is setup tmux as default, and it will load automatically zsh instead of the Bourne Again Shell (Bash).

To setup tmux as default, put this in your ~/.zshrc before your aliases; the code for other shells is very similar:

[[ $TERM != "screen" ]] && exec tmux
Share:
13,325

Related videos on Youtube

Dougui
Author by

Dougui

French Ruby On Rails developer

Updated on September 18, 2022

Comments

  • Dougui
    Dougui over 1 year

    I am using ubuntu gnome 14.04 and I want to have tmux and zsh opened when I start a new terminal.

    For now, in my preference of the terminal, I run tmux by default.

    In the ~/.tmux.conf file I have this :

    set-option -g default-shell /bin/zsh
    

    It works but I have a problem with colors so I need to use TERM=xterm-256color tmux to run tmux. I tried to replace the command launched by default but it produce this error : no such file of this type.

    I tried to run zsh by default and I added this in my ~/.zshrc :

    if [ "$TMUX" = "" ]; then TERM=xterm-256color tmux; fi
    

    It works but it launch zsh then it launch another process with zsh again. It's not very clean and when I try to close the terminal, it say than I have an active process running.

    What can I do to make it work?

  • Dougui
    Dougui about 10 years
    tmux -2 works. I already had set -g default-terminal "screen-256color" in my ~/.tmux.conf.