Skip to content

Instantly share code, notes, and snippets.

@sudkumar
Last active June 9, 2023 06:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sudkumar/6062def9d56d946b98b6a3853093ee74 to your computer and use it in GitHub Desktop.
Save sudkumar/6062def9d56d946b98b6a3853093ee74 to your computer and use it in GitHub Desktop.
How to install tmux locally
#!/bin/bash
# Installing tmux locally
# 1. visit: https://github.com/tmux/tmux
# 2. create a local directory to install tmux
# 3. download depencencies
# 1. libevent
# 1. visit: http://libevent.org/
# 2. download the stable version
# 2. ncurses
# 1. visit: http://invisible-island.net/ncurses/
# 2. download the stable version
# 3. tmux
# 1. visit: https://github.com/tmux/tmux/releases
# 2. download the stable .tar.gz
# 4. install all the dependencies first and last tmux by running following commands
#
# tar xvf [--file--.tar.gz]
# cd [---file--]
# ./configure --prefix=$HOME/local CPPFLAGS="-P"
# make
# make install
#
# 5. `export PATH="$HOME/local/bin:$PATH"` into your bashrc file
rm -rf tmux_temp_installation_dir 2> /dev/null
mkdir tmux_temp_installation_dir
cd tmux_temp_installation_dir
pwd
echo "Please visit http://libevent.org/ and copy the latest stable version's .tar.gz url"
echo "Paste URL"
read libeventurl
echo "Please visit http://invisible-island.net/ncurses/ and copy the latest stable version's .tar.gz url"
echo "Paste URL"
read ncursesurl
echo "Please visit https://github.com/tmux/tmux/releases and copy the latest stable version's .tar.gz url"
echo Paste URL
read tmuxurl
echo "Installing tmux into your ~/.local/bin/tmux"
function installPackage {
# $1 holds tar.gz
rm -rf temp_tmux_install_lib_dir 2> /dev/null
mkdir temp_tmux_install_lib_dir
tar xvf $1 -C temp_tmux_install_lib_dir --strip-components=1
cd temp_tmux_install_lib_dir
ls
./configure --prefix=$HOME/local CPPFLAGS="-P"
make -j 8
make install
cd ..
}
wget $libeventurl -O libevent.tar.gz
wget $ncursesurl -O ncurses.tar.gz
wget $tmuxurl -O tmux.tar.gz
echo "Installing libevent..."
installPackage libevent.tar.gz
echo "Installing ncurses..."
installPackage ncurses.tar.gz
echo "Installing tmux..."
installPackage tmux.tar.gz
echo "Append following line to your .zshrc or .bashrc or .bash_profile file"
echo export PATH="$HOME/local/bin:$PATH"
@WeileiZeng
Copy link

WeileiZeng commented Jun 9, 2023

Thanks for this helpful script. Just to add a bit more to make it a complete instruction

cmd to build tmux after installing dependencies locally

DIR="$HOME/local"
./configure --prefix=$HOME/local CPPFLAGS="-P" CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib"
make && make install

Then in order to use tmux, add path for static libs, e.g. libevent for tmux

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/loca/lib
tmux

reference: https://unix.stackexchange.com/questions/459671/how-do-i-build-tmux-from-source-without-root-access-with-a-custom-built-libevent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment