Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
installation script for tmux 1.9a

Having trouble installing the latest stable version of tmux?

I know, official package for your OS/distro is outdated and you just want the newest version of tmux.

Well, this script should save you some time with that.

Prerequisities

  • gcc
  • wget

Installs

  • tmux - 1.9a (latest stable)
  • libevent - 2.0.21 (latest stable)
  • ncurses - 5.9 (latest stable)

How to install

First of all, you should give me super user permissions, because this will install tmux to /usr/local/lib by default. Trust me, I'm a random guy from the interwebz.

Hit

curl -fsSL https://gist.github.com/shime/5706655/raw/install.sh | sudo bash -e
#!/bin/bash
# Script for installing tmux and dependencies.
# tmux will be installed in /usr/local/lib by default.
# Prerequisites: - gcc
# - wget
# define versions
tmux_version="1.9"
tmux_patch_version="a" # leave empty for stable releases
libevent_version="2.0.21"
ncurses_version="5.9"
tmux_name="tmux-$tmux_version"
tmux_relative_url="$tmux_name/$tmux_name$tmux_patch_version"
libevent_name="libevent-$libevent_version-stable"
ncurses_name="ncurses-$ncurses_version"
# set the installation directory
target_dir="/usr/local"
# download source files for tmux, libevent, and ncurses
# save them in /tmp
cd /tmp
wget -O $tmux_name.tar.gz http://sourceforge.net/projects/tmux/files/tmux/$tmux_relative_url.tar.gz/download
wget -O $libevent_name.tar.gz https://github.com/downloads/libevent/libevent/$libevent_name.tar.gz
wget -O $ncurses_name.tar.gz ftp://ftp.gnu.org/gnu/ncurses/$ncurses_name.tar.gz
# extract files, configure, and compile
# libevent installation
tar xvzf $libevent_name.tar.gz
cd $libevent_name
./configure --prefix=$target_dir --disable-shared
make
make install
cd -
# ncurses installation
tar xvzf $ncurses_name.tar.gz
cd $ncurses_name
./configure --prefix=$target_dir
make
make install
cd -
# tmux installation
tar xvzf ${tmux_name}*.tar.gz
cd ${tmux_name}*/
./configure CFLAGS="-I$target_dir/include -I$target_dir/include/ncurses" LDFLAGS="-L$target_dir/lib -L$target_dir/include/ncurses -L$target_dir/include"
CPPFLAGS="-I$target_dir/include -I$target_dir/include/ncurses" LDFLAGS="-static -L$target_dir/include -L$target_dir/include/ncurses -L$target_dir/lib" make
cp tmux $target_dir/bin
cd -
version=`tmux -V | cut -d ' ' -f 2`
if [ -z "$version" ]; then
echo
echo "[error] failed to install tmux - check for errors in the above output"
exit 1
fi
@liuml07

This comment has been minimized.

Copy link

@liuml07 liuml07 commented Jul 1, 2013

cool!

@mikaelz

This comment has been minimized.

Copy link

@mikaelz mikaelz commented Aug 28, 2013

Trying to compile on a shared hosting in my $HOME but without success :P
libevent is compiled and in $HOME/local

CFLAGS="-I$HOME/local/include" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include" LIBEVENT_CFLAGS="-I$HOME/local/include" LIBEVENT_LIBS="-L$HOME/local/lib" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/local/lib" ./configure --prefix=$HOME/local

LDFLAGS="-static -L$HOME/local/lib -L$HOME/local/include -L$HOME/local/include" CPPFLAGS="-I$HOME/local/include" LIBEVENT_CFLAGS="-I$HOME/local/include" LIBEVENT_LIBS="-L$HOME/local/lib" make

I found https://gist.github.com/536325/91f1392f1ecf46bed893ce5dd882d6018e95e22b and
tried also setting LD_LIBRARY_PATH and LD_RUN_PATH
export LD_LIBRARY_PATH="$HOME/local/lib"
export LD_RUN_PATH="$HOME/local/lib"

@kfatehi

This comment has been minimized.

Copy link

@kfatehi kfatehi commented Jul 30, 2014

not just fancy --- necessary! thank you

@robbyoconnor

This comment has been minimized.

Copy link

@robbyoconnor robbyoconnor commented Aug 21, 2014

You sir, are amazing.

@mdmcaus

This comment has been minimized.

Copy link

@mdmcaus mdmcaus commented Sep 4, 2014

FYI - libevent didn't download properly for me. I'm on Ubuntu 10.04 and had to install it manually because tmux threw an error when running 'make' as shown here:

http://jtskarbek.wordpress.com/2013/03/22/tmux-compile-failure/

Once I downloaded it separately and installed it, everything else worked fine.

@michaelsbradleyjr

This comment has been minimized.

Copy link

@michaelsbradleyjr michaelsbradleyjr commented Sep 8, 2014

Your script doesn't seem to build the man page for tmux. What's the proper way to augment it so that it is built?

@Integralist

This comment has been minimized.

Copy link

@Integralist Integralist commented Sep 20, 2014

The simplest solution is...

add-apt-repository ppa:pi-rho/dev
apt-get update
apt-get install tmux-y
@shime

This comment has been minimized.

Copy link
Owner Author

@shime shime commented Sep 29, 2014

@michaelsbradleyjr man pages are left out because we're not using package manager here. fork away and add support for man pages :)
@Integralist yes if your package manager is aptitude
@mdmcaus I don't know what happened, but link for libevent is correct

@liuyuan10

This comment has been minimized.

Copy link

@liuyuan10 liuyuan10 commented Jan 28, 2015

Works on my Ubuntu 14.04. Thanks!

@wmhilton

This comment has been minimized.

Copy link

@wmhilton wmhilton commented Mar 31, 2015

Thanks!!

Note to others - I recommend closing any existing tmux sessions before launching the new tmux. I didn't, and not sure what happened but I was forced to do a hard reboot. :)

@limingjie

This comment has been minimized.

Copy link

@limingjie limingjie commented Apr 24, 2015

Thank you! Saved me a lot of time!

@felippenardi

This comment has been minimized.

Copy link

@felippenardi felippenardi commented May 29, 2015

@shime Can you update it to tmux 2.0?

@ganiszulfa

This comment has been minimized.

Copy link

@ganiszulfa ganiszulfa commented Dec 16, 2015

if after running this script your tmux is 'still' not upgraded, try

/usr/local/bin/tmux -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.