Skip to content

Instantly share code, notes, and snippets.

@kpj
Last active October 8, 2020 10:46
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 kpj/edf8b8b93d97a3b8f091cff1139060bb to your computer and use it in GitHub Desktop.
Save kpj/edf8b8b93d97a3b8f091cff1139060bb to your computer and use it in GitHub Desktop.
Compiling tmux from scratch
#!/usr/bin/env bash
set -euo pipefail
# (Loosely) based on https://gist.github.com/mbreese/b0630195e57874c87ef3611d059d1bc2
# clean up
rm -rf bin _build _install
# setup
TARGETDIR="$PWD/_install"
mkdir _build && cd _build
# libevent
curl -LO https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
tar -zxvf libevent-2.1.12-stable.tar.gz
cd libevent-2.1.12-stable
./configure \
--prefix=$TARGETDIR
make && make install
cd ..
# ncurses
curl -LO https://github.com/mirror/ncurses/archive/v6.2.tar.gz
tar -zxvf v6.2.tar.gz
cd ncurses-6.2
./configure \
--prefix $TARGETDIR \
--with-default-terminfo-dir=/usr/share/terminfo \
--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" \
--enable-pc-files \
--with-pkg-config-libdir=$TARGETDIR/local/lib/pkgconfig
make && make install
cd ..
# tmux
curl -LO https://github.com/tmux/tmux/releases/download/3.1b/tmux-3.1b.tar.gz
tar -zxvf tmux-3.1b.tar.gz
cd tmux-3.1b
PKG_CONFIG_PATH=$TARGETDIR/lib/pkgconfig ./configure \
--prefix=$TARGETDIR
make && make install
cd ..
# finalize
cd ..
mkdir bin
cat <<EOT >> bin/tmux
LD_LIBRARY_PATH=$TARGETDIR/lib $PWD/_install/bin/tmux "$@"
EOT
echo "export PATH=\"$PWD/bin/:\$PATH\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment