Skip to content

Instantly share code, notes, and snippets.

@m-Just
Last active September 27, 2021 09:02
Show Gist options
  • Save m-Just/d9d33e7bef0d0c6514c526e843f36aac to your computer and use it in GitHub Desktop.
Save m-Just/d9d33e7bef0d0c6514c526e843f36aac to your computer and use it in GitHub Desktop.
Install tmux without root access (from source)
#!/bin/bash
# Adapted from https://gist.github.com/ryin/3106801
# 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
# print commands and their arguments as they are executed
set -x
TMUX_VERSION=3.2a
# create our directories
mkdir -p $HOME/tmux_tmp
cd $HOME/tmux_tmp
# download source files for tmux, libevent, and ncurses
wget https://github.com/tmux/tmux/releases/download/3.2a/tmux-3.2a.tar.gz
wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz
# extract files, configure, and compile
############
# libevent #
############
tar zxf libevent-2.1.12-stable.tar.gz
cd libevent-2.1.12-stable
./configure --prefix=$HOME
# Use this instead if openssl is not available:
# ./configure --prefix=$HOME --disable-openssl
make -j8 && make install
cd ..
############
# ncurses #
############
tar zxf ncurses-6.2.tar.gz
cd ncurses-6.2
./configure --prefix=$HOME
make -j8 && make install
cd ..
############
# tmux #
############
tar zxf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
./configure --prefix=$HOME CFLAGS="-I$HOME/include -I$HOME/include/ncurses" LDFLAGS="-L$HOME/lib"
make -j8 && make install
cd ..
# cleanup
rm -rf $HOME/tmux_tmp
echo "================================"
echo "$HOME/bin/tmux is now available."
echo "Use the following commands to add tmux to your PATH:"
echo 'export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH'
echo 'export PATH=$HOME/bin:$PATH'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment