Create a gist now

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.

Show comment
Hide comment
@adibis

adibis Nov 29, 2012

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

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.

Show comment
Hide comment
@prinny

prinny Jan 11, 2013

Thank you! This worked perfectly for me.

prinny commented Jan 11, 2013

Thank you! This worked perfectly for me.

@jeffdonahue

This comment has been minimized.

Show comment
Hide comment
@jeffdonahue

jeffdonahue 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)...

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.

Show comment
Hide comment
@haridsv

haridsv 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

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.

Show comment
Hide comment
@shime

shime 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.

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.

Show comment
Hide comment
@gundamew

gundamew Aug 8, 2013

Thank you for this script. Clearly and really helped.

gundamew commented Aug 8, 2013

Thank you for this script. Clearly and really helped.

@ZeroDragon

This comment has been minimized.

Show comment
Hide comment
@ZeroDragon

ZeroDragon Sep 25, 2013

Worked on BLUEHOST.com just FYI

Worked on BLUEHOST.com just FYI

@matschaffer

This comment has been minimized.

Show comment
Hide comment
@matschaffer

matschaffer Sep 25, 2013

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

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

@hv15

This comment has been minimized.

Show comment
Hide comment
@hv15

hv15 Dec 2, 2013

Thanks :)

hv15 commented Dec 2, 2013

Thanks :)

@SteveLTN

This comment has been minimized.

Show comment
Hide comment
@SteveLTN

SteveLTN 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!

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.

Show comment
Hide comment
@bodypheo

bodypheo Dec 11, 2013

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

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

@jfmercer

This comment has been minimized.

Show comment
Hide comment
@jfmercer

jfmercer Feb 17, 2014

Many, many, many thanks for this.

Many, many, many thanks for this.

@joshterrell805

This comment has been minimized.

Show comment
Hide comment
@joshterrell805

joshterrell805 Mar 4, 2014

Brilliant! thank you

Brilliant! thank you

@WillXu

This comment has been minimized.

Show comment
Hide comment
@WillXu

WillXu Mar 5, 2014

so brilliant! 

WillXu commented Mar 5, 2014

so brilliant! 

@zephraph

This comment has been minimized.

Show comment
Hide comment
@zephraph

zephraph Mar 5, 2014

Fantastic, thanks!

zephraph commented Mar 5, 2014

Fantastic, thanks!

@jingz

This comment has been minimized.

Show comment
Hide comment
@jingz

jingz May 7, 2014

awesome thanks!

jingz commented May 7, 2014

awesome thanks!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 1, 2014

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

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.

Show comment
Hide comment

Thanks!

@andrewdalecramer

This comment has been minimized.

Show comment
Hide comment
@andrewdalecramer

andrewdalecramer 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!

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.

Show comment
Hide comment

luyifan commented Jul 15, 2014

thanks

@dan-sf

This comment has been minimized.

Show comment
Hide comment
@dan-sf

dan-sf Aug 10, 2014

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

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.

Show comment
Hide comment
@jiacai2050

jiacai2050 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

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.

Show comment
Hide comment
@bouthilx

bouthilx Nov 2, 2014

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

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.

Show comment
Hide comment

chu-NMSU commented Nov 3, 2014

Thanks.

@mnsmar

This comment has been minimized.

Show comment
Hide comment
@mnsmar

mnsmar 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}

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.

Show comment
Hide comment
@aarobc

aarobc Jan 10, 2015

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

aarobc commented Jan 10, 2015

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

@pictodroid

This comment has been minimized.

Show comment
Hide comment
@pictodroid

pictodroid 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

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.

Show comment
Hide comment

Silox commented Feb 24, 2015

👍

@texzhichen

This comment has been minimized.

Show comment
Hide comment
@texzhichen

texzhichen Feb 28, 2015

Very useful shell script, thank you!

Very useful shell script, thank you!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 15, 2015

Excellent, thank you!

ghost commented Mar 15, 2015

Excellent, thank you!

@calebjones

This comment has been minimized.

Show comment
Hide comment
@calebjones

calebjones Apr 13, 2015

Works great!

Works great!

@ysangkok

This comment has been minimized.

Show comment
Hide comment
@ysangkok

ysangkok Apr 16, 2015

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

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

@partoneoftwo

This comment has been minimized.

Show comment
Hide comment
@partoneoftwo

partoneoftwo Jun 23, 2015

This worked perfectly on Inmotion.com shared server.

This worked perfectly on Inmotion.com shared server.

@bmyerz

This comment has been minimized.

Show comment
Hide comment

bmyerz commented Jul 23, 2015

thanks

@bmyerz

This comment has been minimized.

Show comment
Hide comment
@bmyerz

bmyerz Jul 23, 2015

thanks, worked on redhat 4.4 fine

bmyerz commented Jul 23, 2015

thanks, worked on redhat 4.4 fine

@javier-lopez

This comment has been minimized.

Show comment
Hide comment
@javier-lopez

javier-lopez 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

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.

Show comment
Hide comment
@javier-lopez

javier-lopez 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

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.

Show comment
Hide comment
@javier-lopez

javier-lopez 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

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.

Show comment
Hide comment
@javier-lopez

javier-lopez 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

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.

Show comment
Hide comment
@kedare

kedare 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

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.

Show comment
Hide comment
@KDGNOR

KDGNOR Aug 29, 2015

mathieupoussin thx u fix ssl error i got 👍

KDGNOR commented Aug 29, 2015

mathieupoussin thx u fix ssl error i got 👍

@luiarthur

This comment has been minimized.

Show comment
Hide comment
@luiarthur

luiarthur Sep 25, 2015

This is great!

This is great!

@jealie

This comment has been minimized.

Show comment
Hide comment
@jealie

jealie 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.

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.

Show comment
Hide comment
@ycmjason

ycmjason Feb 24, 2016

Amazing script!

Amazing script!

@nemami

This comment has been minimized.

Show comment
Hide comment

nemami commented Mar 9, 2016

Nice!

@kramer33

This comment has been minimized.

Show comment
Hide comment
@kramer33

kramer33 Mar 18, 2016

Thanks, great work!

Thanks, great work!

@GuruKyuu

This comment has been minimized.

Show comment
Hide comment
@GuruKyuu

GuruKyuu 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.

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.

Show comment
Hide comment
@vzhong

vzhong 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

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.

Show comment
Hide comment
@gut

gut Apr 27, 2016

nice! Thanks. Also for version 2.2!

gut commented Apr 27, 2016

nice! Thanks. Also for version 2.2!

@xapple

This comment has been minimized.

Show comment
Hide comment
@xapple

xapple 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 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.

Show comment
Hide comment
@xapple

xapple 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 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.

Show comment
Hide comment
@xapple

xapple 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

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.

Show comment
Hide comment
@cgungor

cgungor 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

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.

Show comment
Hide comment
@pmirajkar

pmirajkar Jul 20, 2016

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

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

@landge

This comment has been minimized.

Show comment
Hide comment
@landge

landge Sep 27, 2016

Thank you! This worked great for me!!

landge commented Sep 27, 2016

Thank you! This worked great for me!!

@bad884

This comment has been minimized.

Show comment
Hide comment
@bad884

bad884 Dec 13, 2016

Thank you!

bad884 commented Dec 13, 2016

Thank you!

@thinki

This comment has been minimized.

Show comment
Hide comment
@thinki

thinki 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```

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.

Show comment
Hide comment
@WesternRanger

WesternRanger 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!

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.

Show comment
Hide comment
@elfosardo

elfosardo Feb 15, 2017

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

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

@annawoodard

This comment has been minimized.

Show comment
Hide comment
@annawoodard

annawoodard Mar 23, 2017

Great script, thanks!

Great script, thanks!

@Kobtul

This comment has been minimized.

Show comment
Hide comment
@Kobtul

Kobtul Apr 7, 2017

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

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.

Show comment
Hide comment
@crobicha

crobicha 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?

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.

Show comment
Hide comment
@smilesun

smilesun 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

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.

Show comment
Hide comment
@biokay

biokay Apr 21, 2017

awesome~

biokay commented Apr 21, 2017

awesome~

@DexHunter

This comment has been minimized.

Show comment
Hide comment
@DexHunter

DexHunter 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

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.

Show comment
Hide comment
@MeteoBoy4

MeteoBoy4 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

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.

Show comment
Hide comment
@iyll

iyll 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

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.

Show comment
Hide comment
@yogeshpv

yogeshpv 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."

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.

Show comment
Hide comment
@junieroliva

junieroliva Sep 5, 2017

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

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

@dajuno

This comment has been minimized.

Show comment
Hide comment
@dajuno

dajuno 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.

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.

Show comment
Hide comment
@xzp27

xzp27 Oct 11, 2017

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

xzp27 commented Oct 11, 2017

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

@thinki

This comment has been minimized.

Show comment
Hide comment
@thinki

thinki 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}"

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.

Show comment
Hide comment
@parth126

parth126 Jan 31, 2018

Thanks a lot mate. You are a life saver.

Thanks a lot mate. You are a life saver.

@derwentx

This comment has been minimized.

Show comment
Hide comment
@derwentx

derwentx 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

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.

Show comment
Hide comment
@mukahraman

mukahraman Mar 17, 2018

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

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.

Show comment
Hide comment
@hmm34

hmm34 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!

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.

Show comment
Hide comment
@congyh

congyh Jun 12, 2018

Thank you so much!

congyh commented Jun 12, 2018

Thank you so much!

@YoungForest

This comment has been minimized.

Show comment
Hide comment
@YoungForest

YoungForest 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.

#!/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.

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