Install tmux on Mac OS X

This is a short run down on how to get tmux running on your Mac OS X system. The same methodology applies when compiling this on Solaris.

What is tmux?

According to the developer's page, "tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached".

Why not just use screen?

For me, the primary reason I switched to tmux from screen is the much easier configuration syntax that tmux offers. If you've ever struggled with formatting screen's caption or hardstatus line, then you will appreciate the ease with which you can achieve the same results in tmux.

Preparing your environment

You will need a C compiler installed. I believe that OS X ships by default with GNU make, but if not, then you will need to obtain it or use Xcode.

Download the sources

While I'm putting all this together, I like to keep everything neatly tucked away in a build directory.
mkdir ~/build
cd ~/build
curl -OL http://downloads.sourceforge.net/tmux/tmux-1.5.tar.gz
curl -OL http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.16-stable.tar.gz

Unpack the sources

tar xzf tmux-1.5.tar.gz
tar xzf libevent-2.0.16-stable.tar.gz

Compiling libevent

cd libevent-2.0.16-stable
./configure --prefix=/opt
make
sudo make install

Compiling tmux

cd ../tmux-1.5
LDFLAGS="-L/opt/lib" CPPFLAGS="-I/opt/include" LIBS="-lresolv" ./configure --prefix=/opt
make
sudo make install
That's all there is to it!
Comments:

Thanks,

Worked perfectly osx 10.5, x-code 3.1.2

Posted by guest on March 01, 2012 at 12:07 PM EST #

Like a charm ... I couldn't get tmux ./configure to find libevent without the LD & CPP Flags ....

Thanks ...

Posted by Edward Beckett on June 30, 2012 at 05:46 PM EST #

Now you really want to do "brew install tmux".

Posted by guest on July 19, 2012 at 05:04 AM EST #

Since posting this entry, I have indeed switched to using Homebrew -
http://mxcl.github.com/homebrew/

Posted by Ben on July 23, 2012 at 04:26 PM EST #

Worked great! Thanks for the easy to follow script!

Posted by Troy on September 11, 2012 at 02:02 AM EST #

Excellent post! Thanks, it works perfectly in Mac OS X 10.7.5.
Cheers,
Fernando

Posted by Fernando Rossello on January 08, 2013 at 02:32 PM EST #

I appreciate the help :)

Posted by shilei on January 11, 2013 at 11:04 AM EST #

Worked great on Mountain Lion, thank you!

Posted by senas on March 30, 2013 at 05:04 AM EST #

Mac OS X - 10.8.3
Works great!

Posted by guest on April 06, 2013 at 06:06 AM EST #

Work flawlessly. Thanks a bunch!

Posted by Miguel Mota on April 30, 2013 at 03:56 AM EST #

after i ran all of the above commands, which worked great, i entered >tmux and got the response "-bash: tmux: command not found." any suggestions?

Posted by guest on September 18, 2013 at 02:28 PM EST #

Tried this in my terminal app and everything went through but at the end when I hit tmux it still says "-bash: tmux: command not found." Is there anything else I need to after the steps you posted.

Posted by guest on November 21, 2013 at 06:48 AM EST #

To those getting the "command not found" error, you must add the tmux installation directory to your path. If you've followed the instructions exactly, the following command will update your path:

export PATH=$PATH:/opt/bin

You should also add this to your shell initialisation files (for bash, edit ~/.bashrc).

Posted by Ben on November 21, 2013 at 08:29 AM EST #

Thank you very much sir. On my own I was not able to identify the problem in my installation. How did you figure out which flags needed to be set in OS X? (it was so easy in Linux) -Cole, thanks in advance for your time

Posted by Cole on December 09, 2013 at 04:24 PM EST #

This is a shell script I use on Mac OS X 10.9 / Mavericks to build a somewhat "static" tmux 1.8.

-------

#!/bin/bash

export CC=clang
export CXX=clang++

# set up a ram disk
DISK_ID=$(hdid -nomount ram://2097152)
newfs_hfs -v Ramdisk ${DISK_ID}
diskutil mount ${DISK_ID}

# set up environment
BUILD_SANDBOX="/Volumes/Ramdisk"
TARGET="${BUILD_SANDBOX}/support"
PATH="${TARGET}/bin:$PATH"

# where tmux should be installed to
MYTARGET="/Users/snowy/.sw/"

# no sandbox, no playtime
cd ${BUILD_SANDBOX} || exit 1

# get pkgconfig
cd ${BUILD_SANDBOX}
curl -L -O http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
tar xzpf pkg-config*
cd pkg-config*
./configure --prefix=${TARGET} --with-pc-path=${TARGET}/lib/pkgconfig --with-internal-glib
make -j 8
make install

# get ncurses
cd ${BUILD_SANDBOX}
curl -L -O http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
tar xzpf ncurses*
cd ncurses*
./configure --prefix=${TARGET} --enable-static --disable-shared
make -j 8
make install

# get libevent
cd ${BUILD_SANDBOX}
curl -L -O https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xzpf libevent*
cd libevent*
./configure --prefix=${TARGET} --enable-static --disable-shared
make -j 8
make install

# set compiler flags
export CFLAGS=-I${TARGET}/include/
export LDFLAGS=-L${TARGET}/lib/
export CPPFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS

# get tmux
cd ${BUILD_SANDBOX}
curl -L -O "http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.8/tmux-1.8.tar.gz"
tar xzpf tmux*
cd tmux*
./configure --prefix="$MYTARGET"
make -j 8

if [ ! -e tmux ]
then
echo "Kaboom, build failed"
exit 1
fi

make install
cd $HOME
umount ${BUILD_SANDBOX}

Posted by Nicholas Stallard on December 12, 2013 at 07:30 AM EST #

Many thanks to you!!! Worked like a charm.

Posted by guest on January 12, 2014 at 06:47 AM EST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Ben is an Enterprise Architect in the Oracle Systems sales consulting business in Melbourne, Australia. This blog focuses on Solaris and Oracle Sun servers, storage and networking.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today