Tmux is a great terminal multiplexer. The Tmux installed by yum is too old1 on my CentOS servers. So I decided to install the latest version of Tmux which supports true colors. Since I do not have root priviledge on the system, I have to build Tmux from source and install it to my custom directory. If that is also what you want to do, then go on reading.

Tmux has two dependency: libevent and ncurses.

Build libevent

wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar zxvf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
mkdir -p $HOME/local
# install libevent under $HOME/local
./configure --prefix="$HOME/local"
make -j && make install

Libevent will be install to $HOME/local.

Build ncurses

wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
tar zxvf ncurses-6.1.tar.gz
cd ncurses-6.1/
./configure --prefix="$HOME/local"
make -j&& make install

The above command will install ncurses under $HOME/local.

Build Tmux

Finally, we build Tmux. Just download the Tmux release tarball and build it:

wget https://github.com/tmux/tmux/releases/download/2.8/tmux-2.8-rc.tar.gz
tar zxvf tmux-2.8-rc.tar.gz
cd tmux-2.8-rc
# the CPPFLAGS and LDFLAGS are important, make sure you have written them correctly, or the build will fail
./configure --prefix=$HOME/local \
    CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" \
    LDFLAGS="-L$HOME/local/lib" 
make -j && make install

After running the above commands, Tmux will be installed to $HOME/local. The tmux executable file is under $HOME/local/bin. Finally, we need to add Tmux executable to PATH variables.

export PATH="$HOME/local/bin:$PATH"

Now, you can use the latest Tmux and configure it as you wish. You may also be interested in this post on how to configure Tmux to support true colors.

References


  1. The version of Tmux installed by yum is 1.8.