-
-
Save Falkor/386827cf00ae94e52a0a759521fa3525 to your computer and use it in GitHub Desktop.
Install tmux 2.9a on centos 7
This file contains 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 -l | |
# Time-stamp: <Wed 2020-12-23 18:59 svarrette> | |
############################################################################ | |
# Install tmux 2.9a on Centos | |
# Adapted from https://gist.github.com/j3j3k/2378f8e7bca7bcda7ffab16b6b97a328 | |
CMD_PREFIX= | |
TMUX_VERSION=2.9a | |
LIBEVENT_VERSION=2.1.10-stable | |
STOWDIR=${STOWDIR:=$HOME/stow} | |
################################################################################ | |
print_error_and_exit() { echo "*** ERROR *** $*"; exit 1; } | |
usage() { | |
cat <<EOF | |
NAME | |
$(basename $0):Build and install using stow tmux version ${TMUX_VERSION} | |
USAGE | |
$0 [-n] | |
$0 [-n] --clean | |
OPTIONS: | |
-n --dry-run: Dry run mode | |
--clean: cleanup and remove build/install files | |
EOF | |
} | |
cleanup() { | |
for n in tmux-${TMUX_VERSION} libevent-${LIBEVENT_VERSION} ; do | |
[ -f "${n}.tar.gz" ] && ${CMD_PREFIX} rm -f ${n}.tar.gz | |
if [ -d "${STOWDIR}/${n}" ]; then | |
${CMD_PREFIX} stow -d ${STOWDIR} -D ${n} | |
${CMD_PREFIX} rm -rf ${STOWDIR}/${n} | |
${CMD_PREFIX} rm -rf ${n} | |
fi | |
done | |
} | |
################################################################################ | |
# Check for options | |
while [ $# -ge 1 ]; do | |
case $1 in | |
-h | --help) usage; exit 0;; | |
-n | --noop | --dry-run) CMD_PREFIX=echo;; | |
-c | --clean) cleanup; exit 0;; | |
*) TMUX_VERSION=$*; break;; | |
esac | |
shift | |
done | |
# install deps | |
# yum install gcc kernel-devel make ncurses-devel stow | |
# Prepare Stow | |
mkdir -p ${STOWDIR} ~/bin ~/include ~/lib | |
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL | |
echo "==> Download and install libevent ${LIBEVENT_VERSION}" | |
[ ! -f "libevent-${LIBEVENT_VERSION}.tar.gz" ] && \ | |
${CMD_PREFIX} curl -LOk https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz | |
# Build if not yet done | |
if [ ! -f "${STOWDIR}/libevent-${LIBEVENT_VERSION}/include/event.h" ]; then | |
echo " ... building libevent " | |
${CMD_PREFIX} tar xf libevent-${LIBEVENT_VERSION}.tar.gz | |
${CMD_PREFIX} cd libevent-${LIBEVENT_VERSION} | |
${CMD_PREFIX} ./configure --prefix=${STOWDIR}/libevent-${LIBEVENT_VERSION} | |
${CMD_PREFIX} make | |
${CMD_PREFIX} make install | |
fi | |
# DOWNLOAD SOURCES FOR TMUX AND MAKE AND INSTALL | |
echo "==> Download and install Tmux ${TMUX_VERSION}" | |
[ ! -f "tmux-${TMUX_VERSION}.tar.gz" ] && \ | |
${CMD_PREFIX} curl -LOk https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz | |
# Build if not yet done | |
if [ ! -f "${STOWDIR}/tmux-${TMUX_VERSION}/bin/tmux" ]; then | |
echo " ... building tmux " | |
${CMD_PREFIX} tar xf tmux-${TMUX_VERSION}.tar.gz | |
${CMD_PREFIX} cd tmux-${TMUX_VERSION} | |
${CMD_PREFIX} ./configure --prefix=${STOWDIR}/tmux-${TMUX_VERSION} | |
${CMD_PREFIX} make | |
${CMD_PREFIX} make install | |
fi | |
echo "=> enable tmux" | |
${CMD_PREFIX} stow -d ${STOWDIR} tmux-${TMUX_VERSION} | |
# ${CMD_PREFIX} pkill tmux | |
# close your terminal window (flushes cached tmux executable) | |
# open new shell and check tmux version | |
${CMD_PREFIX} tmux -V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment