install_tmux

如何在没有root权限的情况下安装tmux

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
#!/bin/bash
# tmux will be installed in $INSTALL_DIR/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.

# exit on error
set -e

TMUX_VERSION=2.7
INSTALL_DIR=/home/dongzx13/tools

# create our directories
mkdir -p $INSTALL_DIR/local $INSTALL_DIR/tmux_tmp
cp ncurses-5.9.tar.gz $INSTALL_DIR/tmux_tmp
cp libevent-2.1.8-stable.tar.gz $INSTALL_DIR/tmux_tmp
cp tmux-2.7.tar.gz $INSTALL_DIR/tmux_tmp
cd $INSTALL_DIR/tmux_tmp

# download source files for tmux, libevent, and ncurses

# extract files, configure, and compile

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

############
# ncurses #
############
if [[ $(fs --version) =~ "afs" ]] && fs whereis "$HOME/local" ; then
NCURSES_OPTION=" --enable-symlinks"
else
NCURSES_OPTION=""
fi

tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$INSTALL_DIR/local $NCURSES_OPTION
make
make install
cd ..
############
# tmux #
############
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
sh ./autogen.sh
./configure CFLAGS="-I$INSTALL_DIR/local/include -I$INSTALL_DIR/local/include/ncurses" LDFLAGS="-L$INSTALL_DIR/local/lib -L$INSTALL_DIR/local/include/ncurses -L$INSTALL_DIR/local/include"
CPPFLAGS="-I$INSTALL_DIR/local/include -I$INSTALL_DIR/local/include/ncurses" LDFLAGS="-static -L$INSTALL_DIR/local/include -L$INSTALL_DIR/local/include/ncurses -L$INSTALL_DIR/local/lib" make
cp tmux $INSTALL_DIR/local/bin
cd ..

# cleanup
rm -rf $INSTALL_DIR/tmux_tmp

echo "$INSTALL_DIR/local/bin/tmux is now available. You can optionally add $INSTALL_DIR/local/bin to your PATH."

参考: no root to install tmux