Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

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

This comment has been minimized.

prinny commented Jan 11, 2013

Thank you! This worked perfectly for me.

@jeffdonahue

This comment has been minimized.

jeffdonahue commented Feb 10, 2013

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

gundamew commented Aug 8, 2013

Thank you for this script. Clearly and really helped.

@ZeroDragon

This comment has been minimized.

ZeroDragon commented Sep 25, 2013

Worked on BLUEHOST.com just FYI

@matschaffer

This comment has been minimized.

matschaffer commented Sep 25, 2013

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

@hv15

This comment has been minimized.

hv15 commented Dec 2, 2013

Thanks :)

@SteveLTN

This comment has been minimized.

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!

@bodypheo

This comment has been minimized.

bodypheo commented Dec 11, 2013

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

@jfmercer

This comment has been minimized.

jfmercer commented Feb 17, 2014

Many, many, many thanks for this.

@joshterrell805

This comment has been minimized.

joshterrell805 commented Mar 4, 2014

Brilliant! thank you

@WillXu

This comment has been minimized.

WillXu commented Mar 5, 2014

so brilliant! 

@zephraph

This comment has been minimized.

zephraph commented Mar 5, 2014

Fantastic, thanks!

@jingz

This comment has been minimized.

jingz commented May 7, 2014

awesome thanks!

@ghost

This comment has been minimized.

ghost commented Jun 1, 2014

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

@pedrormjunior

This comment has been minimized.

pedrormjunior commented Jun 2, 2014

Thanks!

@andrewdalecramer

This comment has been minimized.

andrewdalecramer commented Jun 9, 2014

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

This comment has been minimized.

luyifan commented Jul 15, 2014

thanks

@dan-sf

This comment has been minimized.

dan-sf commented Aug 10, 2014

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

@jiacai2050

This comment has been minimized.

jiacai2050 commented Oct 23, 2014

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

This comment has been minimized.

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

This comment has been minimized.

chu-NMSU commented Nov 3, 2014

Thanks.

@mnsmar

This comment has been minimized.

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

This comment has been minimized.

aarobc commented Jan 10, 2015

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

@pictodroid

This comment has been minimized.

pictodroid commented Jan 24, 2015

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

This comment has been minimized.

Silox commented Feb 24, 2015

👍

@texzhichen

This comment has been minimized.

texzhichen commented Feb 28, 2015

Very useful shell script, thank you!

@ghost

This comment has been minimized.

ghost commented Mar 15, 2015

Excellent, thank you!

@calebjones

This comment has been minimized.

calebjones commented Apr 13, 2015

Works great!

@ysangkok

This comment has been minimized.

ysangkok commented Apr 16, 2015

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

@partoneoftwo

This comment has been minimized.

partoneoftwo commented Jun 23, 2015

This worked perfectly on Inmotion.com shared server.

@bmyerz

This comment has been minimized.

bmyerz commented Jul 23, 2015

thanks

@bmyerz

This comment has been minimized.

bmyerz commented Jul 23, 2015

thanks, worked on redhat 4.4 fine

@javier-lopez

This comment has been minimized.

javier-lopez commented Jul 26, 2015

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

@javier-lopez

This comment has been minimized.

javier-lopez commented Jul 26, 2015

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

@javier-lopez

This comment has been minimized.

javier-lopez commented Jul 26, 2015

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

@javier-lopez

This comment has been minimized.

javier-lopez commented Jul 26, 2015

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

This comment has been minimized.

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

This comment has been minimized.

KDGNOR commented Aug 29, 2015

mathieupoussin thx u fix ssl error i got 👍

@luiarthur

This comment has been minimized.

luiarthur commented Sep 25, 2015

This is great!

@jealie

This comment has been minimized.

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.

@ycmjason

This comment has been minimized.

ycmjason commented Feb 24, 2016

Amazing script!

@nemami

This comment has been minimized.

nemami commented Mar 9, 2016

Nice!

@kramer33

This comment has been minimized.

kramer33 commented Mar 18, 2016

Thanks, great work!

@GuruKyuu

This comment has been minimized.

GuruKyuu commented Apr 14, 2016

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

This comment has been minimized.

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

This comment has been minimized.

gut commented Apr 27, 2016

nice! Thanks. Also for version 2.2!

@xapple

This comment has been minimized.

xapple commented May 4, 2016

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

This comment has been minimized.

xapple commented May 4, 2016

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

This comment has been minimized.

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

This comment has been minimized.

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

@pmirajkar

This comment has been minimized.

pmirajkar commented Jul 20, 2016

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

@landge

This comment has been minimized.

landge commented Sep 27, 2016

Thank you! This worked great for me!!

@bad884

This comment has been minimized.

bad884 commented Dec 13, 2016

Thank you!

@thinki

This comment has been minimized.

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```
@WesternRanger

This comment has been minimized.

WesternRanger commented Feb 8, 2017

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!

@elfosardo

This comment has been minimized.

elfosardo commented Feb 15, 2017

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

@annawoodard

This comment has been minimized.

annawoodard commented Mar 23, 2017

Great script, thanks!

@Kobtul

This comment has been minimized.

Kobtul commented Apr 7, 2017

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

@crobicha

This comment has been minimized.

crobicha commented Apr 7, 2017

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?

@smilesun

This comment has been minimized.

smilesun commented Apr 20, 2017

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

This comment has been minimized.

biokay commented Apr 21, 2017

awesome~

@DexHunter

This comment has been minimized.

DexHunter commented Apr 21, 2017

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

This comment has been minimized.

MeteoBoy4 commented May 31, 2017

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

@iyll

This comment has been minimized.

iyll commented Aug 29, 2017

Thank you for your script, it helps me a lot. However, it must be better to update download link of latest sources of tmux, ncurses and libevent.

I replace them in "# download source files for tmux, libevent, and ncurses" section by the following:

wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz wget http://invisible-island.net/datafiles/release/ncurses.tar.gz

and tmux version should be changed firstly:
TMUX_VERSION=2.5

@yogeshpv

This comment has been minimized.

yogeshpv commented Sep 1, 2017

Edited the script to have right folder path, based on @ZhouYL0213 comment,

#!/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=2.5

# 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 https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz 
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz 
wget http://invisible-island.net/datafiles/release/ncurses.tar.gz

# extract files, configure, and compile

############
# libevent #
############
tar xvzf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..

############
# ncurses  #
############
tar xvzf ncurses.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."
@junieroliva

This comment has been minimized.

junieroliva commented Sep 5, 2017

@smilesun run
export CPPFLAGS="-P"
before the script as per https://stackoverflow.com/a/37475223/130152

@dajuno

This comment has been minimized.

dajuno commented Sep 20, 2017

I have trouble with configuring tmux: libevent is not found. Executing the above scripts gives:

...
checking for LIBEVENT... no
checking for library containing event_init... no
checking event.h usability... yes
checking event.h presence... no
configure: WARNING: event.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: event.h: proceeding with the compiler's result
checking for event.h... yes
configure: error: "libevent not found"

edit: the LDFLAGS was missing $HOME/local/lib64 for libevent. adding -L$HOME/local/lib64 to LDFLAGS in the tmux ./configure and make calls fixed this.

@xzp27

This comment has been minimized.

xzp27 commented Oct 11, 2017

I use script of @yogeshpv, and it works now.
Thanks all of you.

@thinki

This comment has been minimized.

thinki commented Oct 16, 2017

@smilesun
Compile error is caused by GCC Version equaling 5.X which is too higher.
https://dev.openwrt.org/ticket/19749

Modify ncurses source code as below:

--- a/meta/recipes-core/ncurses/ncurses.inc
+++ b/meta/recipes-core/ncurses/ncurses.inc
@@ -26,7 +26,7 @@ ENABLE_WIDEC ?= "true"
 # _GNU_SOURCE is required for widec stuff and is detected automatically
 # for target objects.  But it must be set manually for native and sdk
 # builds.
-BUILD_CPPFLAGS += "-D_GNU_SOURCE"
+BUILD_CPPFLAGS += "-D_GNU_SOURCE -P"

 # natives don't generally look in base_libdir
 base_libdir_class-native = "${libdir}"
@parth126

This comment has been minimized.

parth126 commented Jan 31, 2018

Thanks a lot mate. You are a life saver.

@derwentx

This comment has been minimized.

derwentx commented Feb 9, 2018

Hey there, I tried to run this but https://sourceforge.net/projects/tmux/files/tmux/tmux-1.8/tmux-1.8.tar.gz/download is 404'ing for me :(
And then when I search for tmux on SourceForge, the project doesn't exist: https://sourceforge.net/directory/os:linux/?q=tmux
Any ideas?
EDIT: Solution is in @ZhouYL0213 's comment

@mukahraman

This comment has been minimized.

mukahraman commented Mar 17, 2018

Just updated the links and it is working perfectly. Thanks a lot for saving a lot of my time!

@hmm34

This comment has been minimized.

hmm34 commented Mar 29, 2018

I used the solution in @yogeshpv 's comment. It worked with only one modification: cd to new version of ncurses (as of right now it is ncurses-6.1). Thanks!

@congyh

This comment has been minimized.

congyh commented Jun 12, 2018

Thank you so much!

@YoungForest

This comment has been minimized.

YoungForest commented Jul 1, 2018

#!/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=2.5

# 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 https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz 
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz 
wget http://invisible-island.net/datafiles/release/ncurses.tar.gz

# extract files, configure, and compile

############
# libevent #
############
tar xvzf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..

############
# ncurses  #
############
tar xvzf ncurses.tar.gz
cd ncurses-6.1
./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."

thanks @yogeshpv and @hmm34 's comments.

@musically-ut

This comment has been minimized.

musically-ut commented Aug 16, 2018

The links to libevent and ncurses redirect and wget tries to save them with a different filename.

Have fixed them (i.e. hardcoded) to the correct filenames. Also, bumped tmux version from 2.5 to 2.7.

#!/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=2.7

# 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 https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz 
wget -O libevent-2.1.8-stable.tar.gz https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz 
wget -O ncurses.tar.gz http://invisible-island.net/datafiles/release/ncurses.tar.gz

# extract files, configure, and compile

############
# libevent #
############
tar xvzf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..

############
# ncurses  #
############
tar xvzf ncurses.tar.gz
cd ncurses-6.1
./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."
@danellecline

This comment has been minimized.

danellecline commented Sep 5, 2018

Thanks @musically-ut . Your fixes worked for me.

@jdhao

This comment has been minimized.

jdhao commented Oct 25, 2018

@musically-ut, I see that you put some include dir for LDFLAGS. AFAIK, the LDFLAGS are for library files, not header files. Is there anything that I am missing here? Or because Tmux is different in that it requires us to do so? It seems I can not find some official guide.

@Wario7

This comment has been minimized.

Wario7 commented Nov 7, 2018

@musically-ut script works. Thanks a lot!

@StevenShi-23

This comment has been minimized.

StevenShi-23 commented Nov 12, 2018

To use the latest tmux release v2.8, the following works for me (notice you need to do autogen.sh before using ./configure, and use make -j can speed up the build process):

#!/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=2.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 https://github.com/tmux/tmux/archive/${TMUX_VERSION}.tar.gz 
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 -j
make install
cd ..

############
# ncurses  #
############
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/local
make -j
make install
cd ..

############
# tmux     #
############
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
./autogen.sh
./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."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment