Update: installing tmux 2.1 on Linux

Now (October 2016) it seems that apt-get will install version 2.1 of tmux, so there is no need to go through the manual installation.

sudo apt-get install tmux

To check that it worked:

tmux -V  # should see tmux 2.1 (or higher)

Downloading the tmux.conf

An abbreviated version of the script (further down) which will download my ~/.tmux.conf file and create a ~/build/tmux directory.

#save current location
#create and move to ~/build/tmux dir
mkdir -p ~/build
mkdir -p ~/build/tmux
cd ~/build/tmux
#sort out the tmux.conf
wget www.deanbodenham.com/downloads/tmux.conf
if [ -f "~/.tmux.conf" ]; then cp ~/.tmux.conf ./bak_tmux.conf; fi
cp ./tmux.conf ~/.tmux.conf
#move back
cd "$currentdir"

Fixing the 256 colours

On some Linux distributions the command tmux will not start tmux with 256 colours, and the colours will look a little weird.

More importantly, the active/inactive pane highlighting may not work!

After trying several options on this post, the only one that seemed to work for me was to add the following to the following line to the end of the ~/.bashrc file:

alias tmux='tmux -2'

This can be done simply by entering the following line in the terminal:

echo alias tmux=\'tmux -2\' >> ~/.bashrc

Finally, go to Terminal (or Konsole) - Settings - Edit Current Profile - Appearance and select Linux colors (the option Dark Pastels, which is sometimes the default, will mess up the active/inactive shading).

Installing tmux resurrect

See this post for more about tmux-resurrect. To install it you will need to have Git installed:

cd ~/build/tmux
# install tmux-resurrect
git clone https://github.com/tmux-plugins/tmux-resurrect ~/build/tmux-resurrect/
cd "$currentdir"
# resurrect installed

The tmux.conf file contains the necessary lines to make tmux-resurrect work.

Manual installation of tmux 2.2 on Linux

Here is a short script to install tmux 2.2 on Linux into the folder ~/build/tmux/. Just copy/paste the commands into a terminal (you will be asked to enter your superuser password once or twice), and that is it.

This script was created to help me get up and running quickly with fresh installs. It is broken down into four steps (although in Step 0 first check the version numbers are correct, and that wget is installed.

Step 0: Check wget, and libevent/tmux versions

  • Make sure that the wget tool is installed (it comes pre-installed with standard with Ubuntu).
  • libevent allows tmux to handle separate threads. Check what the latest version number is at http://libevent.org/ (look under Download-Stable releases). If necessary, replace the version number in the script below (2.0.22) with another version number.
  • Check the tmux version at https://tmux.github.io/ and if necessary, change the version number in the script below (2.2) to another version number.

Step 1: Download the necessary files

Copy/paste the following into a terminal. To paste, use Ctrl-Shift-v.

#save current location
#create and move to ~/build/tmux dir
if [ -d "~/build" ]; then cd ~/build; else mkdir ~/build; cd ~/build; fi
if [ -d "./tmux" ]; then cd ./tmux; else mkdir tmux; cd ./tmux; fi
#sort out the tmux.conf
wget www.deanbodenham.com/downloads/tmux.conf
if [ -f "~/.tmux.conf" ]; then cp ~/.tmux.conf ./bak_tmux.conf; fi
cp ./tmux.conf ~/.tmux.conf
#get tmux 2.2
wget https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz
#get libevent - go to www.libevent.org to see latest version
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
#unzip the tarballs:
tar xzf libevent-2.0.22-stable.tar.gz
tar xzf tmux-2.2.tar.gz
#optional: if you want to remove the tarballs, re-enter the previous line without the #
# rm *.gz

Step 0.5: Preliminaries

I needed to install the following packages in order for libevent to install on Linux Mint Xfce, but this step was not necessary on Linux Mint Cinnamon. Anyway, it is worth including:

sudo apt-get install autotools-dev
sudo apt-get install automake
sudo apt-get install build-essential libtool
sudo apt-get install libncurses5-dev libncursesw5-dev

Without these packages, the Makefiles would not be built (on Xfce).

Sources: for libtoolize (libevent), for aclocal (libevent), for ncurses (tmux)

Step 1: Install libevent

# now install libevent - will need to enter superuser password
cd ~/build/tmux/libevent-2.0.22-stable
# probably need the next step in order to build the Makefile 
#now can finally build libevent
./configure && make
sudo make install

(You will probably be prompted for your superuser password here)

Step 2: Install tmux

# now install tmux - might/might not need to enter password
cd ~/build/tmux/tmux-2.2
./configure && make
#probably not be necessary
#sudo make install

Step 3: Modify the .bash_profile PATH

# modify PATH to make tmux visible
echo export PATH=~/build/tmux-2.2:\$PATH >> ~/.bash_profile
source ~/.bash_profile
#now check the version
tmux -V

If everything worked, you should see

tmux 2.2

Step 4: tmux resurrect

See this post for more about tmux-resurrect. To install it you will need to have Git installed:

# install tmux-resurrect
git clone https://github.com/tmux-plugins/tmux-resurrect ~/build/tmux-resurrect/
# resurrect installed

In Step 2 the tmux.conf file was downloaded which contains the necessary lines to make tmux-resurrect work.

Step 5: Move back to previous location

The following will move you back to the directory you were in before starting the installation:

#move back
cd "$currentdir"


Troubleshooting the colorscheme

When you start up tmux and open a few panes, it should look something like the figure below (where the bash pane in the top-right corner is active).

bash pane is active

If not, and the colours code look very dark, you need to change the settings in your terminal emulator. What you do depends on what system you are running. For now, I will assume you are running Linux Mint (Ubuntu), but there are different front-ends: KDE, Cinnamon and Xfce.

In order to use the wombat16 colorscheme, in the terminal window, select:

EditProfile preferencesColorsPalletteBuilt-in schemes

and then select Linux console or Xterm. This is to make "greying" work between active/inactive panes on tmux.

If you' using KDE and Konsole, then go to: SettingsEdit Current ProfileAppearance and select Linux colors

In Xfce, I needed to modify the ~/.bashrc file using the following line:

echo ' ' >> ~/.bashrc
echo '#setting terminal to 256 colours for tmux' >> ~/.bashrc
echo 'export TERM=xterm-256color' >> ~/.bashrc
echo ' ' >> ~/.bashrc

which appends a line to the file and forces Xterm to use 256 colours.

(It is this post on Stackoverflow, which is not the accepted answer, although the accepted answer is already included in the tmux.conf file).

Troubleshooting the installation

If in Step 3 tmux -V does not work, try running the following lines:

cd ~/tmux/build/tmux-2.2
sudo make install

This does not seem to be necessary, which is why it was commented out in Step 3.