Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
# create our directories
mkdir -p $HOME/local $HOME/tmux_tmp
cd $HOME/tmux_tmp
# download source files for tmux, libevent, and ncurses
wget -O tmux-${TMUX_VERSION}.tar.gz http://sourceforge.net/projects/tmux/files/tmux/tmux-${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz/download
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
# extract files, configure, and compile
############
# libevent #
############
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-2.0.19-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..
############
# ncurses #
############
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/local
make
make install
cd ..
############
# tmux #
############
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
./configure CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include"
CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib" make
cp tmux $HOME/local/bin
cd ..
# cleanup
rm -rf $HOME/tmux_tmp
echo "$HOME/local/bin/tmux is now available. You can optionally add $HOME/local/bin to your PATH."

adibis commented Nov 29, 2012

Oh - thank you, thank you, thank you. They only had screen at work. Now I can use tmux and be happy :)

prinny commented Jan 11, 2013

Thank you! This worked perfectly for me.

Thanks so much, installed perfectly right out of the box. I hate having to figure out what libraries I need and where to get them for local installs, this saved me probably hours of pain (or from just continuing to use screen on machines I don't have root access for)...

haridsv commented Feb 26, 2013

I modified it to link statically and the resultant binary worked on a different system with different libc: https://gist.github.com/haridsv/5040047

shime commented Jun 4, 2013

Thanks!

Forked this and made it more customizable, updated versions of installed components and provided auto-install command.

Check it out at https://gist.github.com/shime/5706655.

gundamew commented Aug 8, 2013

Thank you for this script. Clearly and really helped.

Worked on BLUEHOST.com just FYI

Oh man, thanks for this. So much time savings.

hv15 commented Dec 2, 2013

Thanks :)

SteveLTN commented Dec 5, 2013

Thank you so much! I got an ssh account to a cluster from my university, but it doesn't have Tmux installed. Now with your script, my life is much easier!

You are a king among men. ;) Kudos to you-

Many, many, many thanks for this.

Brilliant! thank you

WillXu commented Mar 5, 2014

so brilliant! 

zephraph commented Mar 5, 2014

Fantastic, thanks!

jingz commented May 7, 2014

awesome thanks!

@ghost

ghost commented Jun 1, 2014

Thanks! Cannot stand screen. Now to waste some hours trying to understand why what I tried failed...

Thanks!

At the risk of repeated others, thanks so much for this! I've used it as a base to install Vim and tig as well. For the life of me couldn't figure out how to do it before now!

luyifan commented Jul 15, 2014

thanks

dsfcode commented Aug 10, 2014

This is awesome, thanks so much! We only have screen at work so getting tmux was a must.

I met a problem when exec
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz

--2014-10-23 11:08:44-- https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
Resolving github.com... 192.30.252.128
Connecting to github.com|192.30.252.128|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz [following]
--2014-10-23 11:08:46-- https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
Resolving cloud.github.com... 54.230.125.200, 205.251.212.199, 54.230.126.47, ...
Connecting to cloud.github.com|54.230.125.200|:443... connected.
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Unable to establish SSL connection.

my os is centos6.5 64bit

bouthilx commented Nov 2, 2014

I had the same problem. I manually downloaded libevent-2.0.19-stable.tar.gz and then everything worked fine.

chu-NMSU commented Nov 3, 2014

Thanks.

mnsmar commented Dec 16, 2014

Got the following error:
tmux: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

Had to:
export LD_LIBRARY_PATH=/path/to/my/home/local/lib/:${LD_LIBRARY_PATH}

aarobc commented Jan 10, 2015

@jiacai2050 change the
wget
to:
curl -L -O

with curl -L -O I'm getting error SSL routines: SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
with curl -O I can download something but is not a tar ball

Silox commented Feb 24, 2015

👍

Very useful shell script, thank you!

@ghost

ghost commented Mar 15, 2015

Excellent, thank you!

Works great!

Shouldn't it be -L$HOME/local/lib/ncurses instead of -L$HOME/local/include/ncurses ?

This worked perfectly on Inmotion.com shared server.

bmyerz commented Jul 23, 2015

thanks

bmyerz commented Jul 23, 2015

thanks, worked on redhat 4.4 fine

Other alternative could be to fetch the static binary with static-get, no compiler required =)

sh <(wget -qO- s.minos.io/s) -x tmux-2.0

To list all available versions:

sh <(wget -qO- s.minos.io/s) -s -v tmux

https://github.com/minos-org/minos-static

Other alternative could be to fetch the static binary with static-get, no compiler required =)

sh <(wget -qO- s.minos.io/s) -x tmux-2.0

To list all available versions:

sh <(wget -qO- http://s.minos.io/s) -s -v tmux

https://github.com/minos-org/minos-static

Other alternative could be to fetch the static binary with static-get, no compiler required =)

sh <(wget -qO- http://s.minos.io/s) -x tmux-2.0

To list all available versions:

sh <(wget -qO- http://s.minos.io/s) -s -v tmux

https://github.com/minos-org/minos-static

Other alternative could be to fetch the static binary with static-get, no compiler required =)

sh <(wget -qO- http://s.minos.io/s) -x tmux-2.0

To list all available versions:

sh <(wget -qO- http://s.minos.io/s) -v -s tmux

https://github.com/minos-org/minos-static

kedare commented Aug 28, 2015

The WGET SSL error is due to an old version of wget not supporting SNI, just replace the line that download libevent source by this one :

curl https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz > libevent-2.0.19-stable.tar.gz

KDGNOR commented Aug 29, 2015

mathieupoussin thx u fix ssl error i got 👍

This is great!

jealie commented Jan 21, 2016

Awesome script!

I forked it to use automatically the latest version of tmux (currently version 2.1) from the github repo: https://github.com/jealie/install_tmux

This version relies on git to fetch the source, which also solves the SSL error some people had.

Amazing script!

nemami commented Mar 9, 2016

Nice!

Thanks, great work!

I'm getting 404 errors when trying to wget the tmux tarball. Does this need to be updated? SourceForge doesn't seem to have tmux version 2.2.

vzhong commented Apr 25, 2016

For version 2.2:

  1. Change TMUX_VERSION=2.2
  2. Change URL to https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz

gut commented Apr 27, 2016

nice! Thanks. Also for version 2.2!

xapple commented May 4, 2016 edited

I just tried this script with version 2.2 on a fresh linux install (apricityos) and got this error:

In file included from ../ncurses/curses.priv.h:283:0,
                 from ../ncurses/lib_gen.c:19:
_11601.c:835:15: error: expected ‘)’ before ‘int’
../include/curses.h:1594:56: note: in definition of macro ‘mouse_trafo’
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
                                                        ^
Makefile:785: recipe for target '../objects/lib_gen.o' failed
make[1]: *** [../objects/lib_gen.o] Error 1
make[1]: Leaving directory '/home/xapple/tmux_tmp/ncurses-5.9/ncurses'
Makefile:109: recipe for target 'all' failed
make: *** [all] Error 2

xapple commented May 4, 2016 edited

I managed to compile tmux version 2.2 finally (on ubuntu 14.04). But when I copy the executable binary to another computer I get the following:

xapple@uni_cluster test $ ./tmux -V
./tmux: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./tmux)
./tmux: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by ./tmux)
./tmux: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ./tmux)

Is there any way to change the compilation to include these libraries ?

xapple commented May 5, 2016

If anyone comes looking for it, this is the script that was able to install the latest version of tmux:

#!/bin/bash
# Exit on error #
set -e

# Clean up #
rm -rf ~/programs/libevent
rm -rf ~/programs/ncurses
rm -rf ~/programs/tmux

# Variable version #
TMUX_VERSION=2.2

# Create our directories #
mkdir -p ~/test
mkdir -p ~/programs/libevent
mkdir -p ~/programs/ncurses
mkdir -p ~/programs/tmux

############
# libevent #
############
cd ~/test
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-*/
./configure --prefix=$HOME/programs/libevent --disable-shared
make
make install

############
# ncurses  #
############
cd ~/test
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/programs/ncurses LDFLAGS="-static"
make
make install

############
# tmux     #
############
cd ~/test
wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}

# open configure and find the line that says:
# PKG_CONFIG="pkg-config --static"
# And comment it out:
# #PKG_CONFIG="pkg-config --static"

# Build #
./configure --prefix=$HOME/programs/tmux --enable-static CFLAGS="-I$HOME/programs/libevent/include -I$HOME/programs/ncurses/include/ncurses" LDFLAGS="-static -L$HOME/programs/libevent/lib -L$HOME/programs/libevent/include -L$HOME/programs/ncurses/lib -L$HOME/programs/ncurses/include/ncurses" PKG_CONFIG=/bin/false
CPPFLAGS="-I$HOME/programs/libevent/include -I$HOME/programs/ncurses/include/ncurses" LDFLAGS="-static -L$HOME/programs/libevent/lib -L$HOME/programs/libevent/include -L$HOME/programs/ncurses/lib -L$HOME/programs/ncurses/include/ncurses" make

# Move #
cp tmux ~/bin/tmux

cgungor commented May 26, 2016

With the latest script in the comment, I had the following compiler error. Any ideas?

cc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="2.2" -DPACKAGE_STRING="tmux\ 2.2" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="2.2" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DIRENT_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_PATHS_H=1 -DHAVE_PTY_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_DIR_H=1 -DHAVE_DIRFD=1 -DHAVE_FLOCK=1 -DHAVE_SYSCONF=1 -DHAVE_CFMAKERAW=1 -DHAVE_B64_NTOP=1 -DHAVE_FORKPTY=1 -DHAVE_DAEMON=1 -DHAVE_SETENV=1 -DHAVE_ASPRINTF=1 -DHAVE_STRCASESTR=1 -DHAVE_STRSEP=1 -DHAVE_CFMAKERAW=1 -DHAVE_OPENAT=1 -DHAVE_DECL_OPTARG=1 -DHAVE_DECL_OPTIND=1 -DHAVE_DECL_OPTRESET=0 -DHAVE_BSD_TYPES=1 -DHAVE___PROGNAME=1 -DHAVE_PROC_PID=1 -I. -I/usr/include/ncursesw -DTMUX_CONF=""/etc/tmux.conf"" -iquote. -I/home/phd/e1696798/programs/libevent/include -I/home/phd/e1696798/programs/ncurses/include/ncurses -D_GNU_SOURCE -std=gnu99 -O2 -MT tty-term.o -MD -MP -MF $depbase.Tpo -c -o tty-term.o tty-term.c &&
mv -f $depbase.Tpo $depbase.Po
tty-term.c: In function ‘tty_term_find’:
tty-term.c:410:37: error: ‘OK’ undeclared (first use in this function)
if (setupterm(name, fd, &error) != OK) {
^
tty-term.c:410:37: note: each undeclared identifier is reported only once for each function it appears in
make: *** [tty-term.o] Error 1

Thank you very much! Really clean script with everything in one place!
You are the real MVP!

landge commented Sep 27, 2016

Thank you! This worked great for me!!

bad884 commented Dec 13, 2016

Thank you!

thinki commented Jan 9, 2017

xapple's script miss some include directory, script below works OK for me:

# Exit on error #
set -e

# Clean up #
rm -rf ~/tools/programs/libevent
rm -rf ~/tools/programs/ncurses
rm -rf ~/tools/programs/tmux

# Variable version #
TMUX_VERSION=2.2

# Create our directories #
mkdir -p ~/tools/test
mkdir -p ~/tools/programs/libevent
mkdir -p ~/tools/programs/ncurses
mkdir -p ~/tools/programs/tmux

############
# libevent #
############
cd ~/tools/test
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-*/
./configure --prefix=$HOME/tools/programs/libevent --disable-shared
make
make install

############
# ncurses  #
############
cd ~/tools/test
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/tools/programs/ncurses LDFLAGS="-static"
make
make install

############
# tmux     #
############
cd ~/tools/test
wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}

# open configure and find the line that says:
# PKG_CONFIG="pkg-config --static"
# And comment it out:
# #PKG_CONFIG="pkg-config --static"

# Build #
./configure --prefix=$HOME/tools/programs/tmux --enable-static CFLAGS="-I$HOME/tools/programs/libevent/include -I$HOME/tools/programs/ncurses/include/ncurses -I$HOME/tools/programs/ncurses/include/" LDFLAGS="-static -L$HOME/tools/programs/libevent/lib -L$HOME/tools/programs/libevent/include -L$HOME/tools/programs/ncurses/lib -L$HOME/tools/programs/ncurses/include/ncurses" PKG_CONFIG=/bin/false
CPPFLAGS="-I$HOME/tools/programs/libevent/include -I$HOME/tools/programs/ncurses/include/ncurses" LDFLAGS="-static -L$HOME/tools/programs/libevent/lib -L$HOME/tools/programs/libevent/include -L$HOME/tools/programs/ncurses/lib -L$HOME/tools/programs/ncurses/include/ncurses" make

# Move #
cp tmux ~/bin/tmux```

Thanks for your share!!! but the source files for tmux could be changed. I take a long time to find the solution:

https://github.com/tmux/tmux/releases/download/2.1/tmux-2.1.tar.gz  

use above addr instead.

good luck!

great script, thanks!
I forked it to add some flexibility and options and correct the urls :)

Great script, thanks!

Kobtul commented Apr 7, 2017

Really thanks! I needed to adjust the wgets for the new version but it is working now

crobicha commented Apr 7, 2017 edited

Updated to latest version (2.3) and using github instead of sourceforge - https://gist.github.com/crobicha/f99b5f626c47473a184003ae1fc597d4

I would create a pull-request but it seems like that's only a git concept, not in gist?

I met the following problem when make ncurses

In file included from ../ncurses/curses.priv.h:283:0,
                 from ../ncurses/lib_gen.c:19:
_1517.c:835:15: error: expected ‘)’ before ‘int’
../include/curses.h:1594:56: note: in definition of macro ‘mouse_trafo’
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
                                                        ^
make[1]: *** [../objects/lib_gen.o] Error 1
make[1]: Leaving directory `/home/hpc/pr74ze/ru37wof2/tmux_tmp/ncurses-5.9/ncurses'
make: *** [all] Error 2

biokay commented Apr 21, 2017

awesome~

Just removed the last three backquote from the above script and finally works fine without thinking.

# Exit on error #
set -e

# Clean up #
rm -rf ~/tools/programs/libevent
rm -rf ~/tools/programs/ncurses
rm -rf ~/tools/programs/tmux

# Variable version #
TMUX_VERSION=2.2

# Create our directories #
mkdir -p ~/tools/test
mkdir -p ~/tools/programs/libevent
mkdir -p ~/tools/programs/ncurses
mkdir -p ~/tools/programs/tmux

############
# libevent #
############
cd ~/tools/test
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-*/
./configure --prefix=$HOME/tools/programs/libevent --disable-shared
make
make install

############
# ncurses  #
############
cd ~/tools/test
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/tools/programs/ncurses LDFLAGS="-static"
make
make install

############
# tmux     #
############
cd ~/tools/test
wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}

# open configure and find the line that says:
# PKG_CONFIG="pkg-config --static"
# And comment it out:
# #PKG_CONFIG="pkg-config --static"

# Build #
./configure --prefix=$HOME/tools/programs/tmux --enable-static CFLAGS="-I$HOME/tools/programs/libevent/include -I$HOME/tools/programs/ncurses/include/ncurses -I$HOME/tools/programs/ncurses/include/" LDFLAGS="-static -L$HOME/tools/programs/libevent/lib -L$HOME/tools/programs/libevent/include -L$HOME/tools/programs/ncurses/lib -L$HOME/tools/programs/ncurses/include/ncurses" PKG_CONFIG=/bin/false
CPPFLAGS="-I$HOME/tools/programs/libevent/include -I$HOME/tools/programs/ncurses/include/ncurses" LDFLAGS="-static -L$HOME/tools/programs/libevent/lib -L$HOME/tools/programs/libevent/include -L$HOME/tools/programs/ncurses/lib -L$HOME/tools/programs/ncurses/include/ncurses" make

# Move #
cp tmux ~/bin/tmux

MeteoBoy4 commented May 31, 2017 edited

Thanks a lot for your codes! I would like to ask why sometimes there is 'prefix' when configure tmux and sometimes not? If not, where do we indicate tmux should be installed? And why there are two LDFLAGS (almost the same) when configuring tmux? @DexHunter @thinki @xapple @ryin @crobicha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment