Recently I needed to install tmux on a server which runs some ancient RHEL and I do not have sudo access to. Here is how I did it. In fact it has tmux 1.6 pre-installed, but my tmux configuration file is based on tmux 2.2, which contains many options that are absent in earlier versions of tmux.

Libevent Setup

libevent will be most likely missing (as it is in my case). So first, let's set it up. Download the tarball from http://libevent.org/, extract it, configure and install.

$ wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
$ tar xvf libevent-2.0.22-stable.tar.gz
$ cd libevent-2.0.22-stable
$ ./configure --prefix=$HOME
$ make # use make -j 8 to speed it up if your machine is capable
$ make install

Note that since I do not have root access to this machine, I set the installation prefix to be my home directory.

Tmux Setup

Second, download the tmux source tarball from https://tmux.github.io/. As of writing this blog, the latest version is 2.2.

$ wget https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz
$ tar xvf tmux-2.2
$ ./configure --prefix=$HOME CFLAGS="-I$HOME/include" LDFLAGS="-L$HOME/lib"
$ make
$ make install

Again, I set the installation prefix to be my home directory, and also tells gcc where to find the libevent headers and libraries using the CCFLAGS and LDFLAGS.

$PATH Setup

After this, tmux binary will be installed in $HOME/bin. Finally, we need to tweak the $PATH variable a bit so that bash will find this binary before the system one.

$ export PATH=$HOME/bin:$PATH

You may want to also put the above line in your .bashrc.

Now you should be able to use the shiningly new tmux.

$ tmux -V
tmux 2.2