Skip to content

Instantly share code, notes, and snippets.

@FullStackAlex
Forked from ryin/tmux_local_install.sh
Last active May 10, 2020 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FullStackAlex/c4582f4bdf8003d14b1e22d23aaac1e0 to your computer and use it in GitHub Desktop.
Save FullStackAlex/c4582f4bdf8003d14b1e22d23aaac1e0 to your computer and use it in GitHub Desktop.
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on a Mac without sudo
# tmux will be installed in $NOSUDO.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=3.1b
LIBEVENT_VERSION=2.1.11
NCURSES_VERSION=6.2
NOSUDO=$HOME/Tech/nosudo
TEMP=$TMPDIR/tmux_tmp
CORES=$(sysctl -n hw.logicalcpu)
# create our directories
mkdir -p $NOSUDO $TEMP
cd $TEMP
# extract files, configure, and compile
############
############
curl -OL "https://github.com/libevent/libevent/releases/download/release-$LIBEVENT_VERSION-stable/libevent-$LIBEVENT_VERSION-stable.tar.gz"
tar xvzf libevent-$LIBEVENT_VERSION-stable.tar.gz
cd libevent-2.1.11-stable
./configure --prefix=$NOSUDO --disable-shared
# make make faster
make -j $CORES
make install
cd ..
############
# ncurses #
############
curl -OL "ftp://ftp.gnu.org/gnu/ncurses/ncurses-$NCURSES_VERSION.tar.gz"
# libevent #
tar xvzf ncurses-$NCURSES_VERSION.tar.gz
cd ncurses-$NCURSES_VERSION
./configure --prefix=$NOSUDO
make -j $CORES
make install
cd ..
############
# tmux #
############
curl -OL "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
./configure CFLAGS="-I$NOSUDO/include -I$NOSUDO/include/ncurses" LDFLAGS="-L$NOSUDO/lib -L$NOSUDO/include/ncurses -L$NOSUDO/include"
CPPFLAGS="-I$NOSUDO/include -I$NOSUDO/include/ncurses" LDFLAGS="-static -L$NOSUDO/include -L$NOSUDO/include/ncurses -L$NOSUDO/lib" make
cp tmux $NOSUDO/bin
cd ..
# cleanup
rm -rf $TEMP
echo "$NOSUDO/bin/tmux is now available. Don't forget to add $NOSUDO/bin to your PATH in your ~/.bash_profile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment