-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall_tmux.sh
executable file
·71 lines (56 loc) · 2.22 KB
/
install_tmux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# The latest version of tmux will be installed in $HOME/local/bin.
# It is assumed that standard compilation tools (a C/C++ compiler with autoconf) are available. If git is installed it will be used instead of curl.
# Modified from https://gist.github.com/ryin/3106801 and https://gist.github.com/ryin/3106801 to use the latest version from github.
# exit on error
set -e
get_from_github () {
if type "git" &> /dev/null ; then
git clone https://github.com/$1/$1
else
curl -L https://github.com/$1/$1/archive/master.tar.gz -o $1.tar.gz
tar xvzf $1.tar.gz
fi
}
# create our directories
mkdir -p $HOME/local $HOME/tmux_tmp
cd $HOME/tmux_tmp
# download source files for tmux, libevent, and ncurses
get_from_github tmux
get_from_github libevent
curl -L ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz -o ncurses.tar.gz
tar xvzf ncurses.tar.gz
#########################
# configure and compile #
#########################
# get the number of CPU cores for build
if [ -f /proc/cpuinfo ]; then
CPUS=`grep processor /proc/cpuinfo | wc -l`
else
CPUS=2
fi
# libevent
cd $HOME/tmux_tmp/libevent*
./autogen.sh
./configure --prefix=$HOME/local --disable-shared
make -j$CPUS
make install
# ncurses
cd $HOME/tmux_tmp/ncurses-*
export CPPFLAGS="-P" # otherwise ncurse fails to build on gcc 5.x (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61832)
./configure --prefix=$HOME/local --without-debug --without-shared --without-normal --without-ada
make -j$CPUS
make install
# tmux
cd $HOME/tmux_tmp/tmux*
./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 -j$CPUS
cp tmux $HOME/local/bin
# cleanup
rm -rf $HOME/tmux_tmp
echo -e "\n\n$HOME/local/bin/tmux is now available. Make it accessible by adding to your .bashrc or .bash_profile:"
echo -e "\nSolution 1: append it to your PATH:\n export PATH=\$PATH:$HOME/local/bin"
echo -e "\nSolution 2: create an alias:\n alias tmux=$HOME/local/bin/tmux"