-
-
Save SongRb/e1a2059b6620407c260c71a2b56a7c3c to your computer and use it in GitHub Desktop.
Install tmux locally without root access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script for installing tmux on systems where you don't have root access. | |
# 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 | |
LIBEVENT_VERSION=2.1.8-stable | |
NCURSES_VERSION=6.1 | |
INSTALL_DIR=$HOME | |
# create our directories | |
mkdir -p $INSTALL_DIR/local $INSTALL_DIR/tmux_tmp | |
cd $INSTALL_DIR/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-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz | |
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.gz | |
# extract files, configure, and compile | |
############ | |
# libevent # | |
############ | |
tar xvzf libevent-${LIBEVENT_VERSION}.tar.gz | |
cd libevent-${LIBEVENT_VERSION} | |
./configure --prefix=$INSTALL_DIR/local --disable-shared | |
make -j | |
make install | |
cd .. | |
############ | |
# ncurses # | |
############ | |
if fs && [[ $(fs --version) =~ "afs" ]] && fs whereis "$HOME/local" ; then | |
NCURSES_OPTION=" --enable-symlinks" | |
else | |
NCURSES_OPTION="" | |
fi | |
tar xvzf ncurses-${NCURSES_VERSION}.tar.gz | |
cd ncurses-${NCURSES_VERSION} | |
./configure --prefix=$INSTALL_DIR/local $NCURSES_OPTION | |
make -j 4 | |
make install | |
cd .. | |
############ | |
# tmux # | |
############ | |
tar xvzf tmux-${TMUX_VERSION}.tar.gz | |
cd tmux-${TMUX_VERSION} | |
./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 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/lib' >> ~/.bashrc | |
echo "alias tmux=${INSTALL_DIR}/local/bin/tmux" | |
echo "$INSTALL_DIR/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