-
-
Save 404NetworkError/c01fb57addeb266d6272a157781b48b3 to your computer and use it in GitHub Desktop.
bash script for installing tmux & htop without root access
This file contains hidden or 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 | |
# Script for installing tmux & htop on systems where you don't have root access. | |
# tmux & htop will be installed in $HOME/.local/bin. | |
# exit on error | |
set -e | |
# Required commands for script | |
if ! command -v wget >/dev/null 2>&1; then | |
echo "ERROR: missing \`wget\`" | |
exit 1 | |
elif ! command -v make >/dev/null 2>&1; then | |
echo "ERROR: missing \`make\`" | |
exit 1 | |
elif ! command -v gcc >/dev/null 2>&1; then | |
echo "ERROR: missing C/C++ compiler" | |
exit 1 | |
elif ! command -v python >/dev/null 2>&1; then | |
echo "ERROR: missing Python" | |
exit 1 | |
fi | |
TMUX_VERSION=2.8 | |
LIBEVENT_VERSION=2.1.8 | |
NCURSES_VERSION=6.1 | |
HTOP_VERSION=2.2.0 | |
# for make | |
function make_jobs () { | |
if [[ $(expr $(nproc) / 2) -le 0 ]]; then | |
jobs=1 | |
else | |
jobs=$(expr $(nproc) / 2) | |
fi | |
} | |
make_jobs | |
# Create necessary folders | |
mkdir -p $HOME/.local/bin | |
# download source files for tmux, libevent, ncurses, and htop | |
wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz | |
wget -O libevent-${LIBEVENT_VERSION}-stable.tar.gz https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}-stable/libevent-${LIBEVENT_VERSION}-stable.tar.gz | |
wget -O ncurses-${NCURSES_VERSION}.tar.gz https://ftp.gnu.org/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.gz | |
wget -O htop-${HTOP_VERSION}.tar.gz https://hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz | |
# extract files, configure, and compile | |
############ | |
# libevent # | |
############ | |
echo -e "\n~~ libevent ~~" | |
tar xvzf libevent-${LIBEVENT_VERSION}-stable.tar.gz | |
cd libevent-${LIBEVENT_VERSION}-stable | |
./configure --prefix=$HOME/.local --disable-shared | |
make -j ${jobs} | |
make -j ${jobs} install | |
cd .. | |
############ | |
# ncurses # | |
############ | |
echo -e "\n~~ ncurses ~~" | |
tar xvzf ncurses-${NCURSES_VERSION}.tar.gz | |
cd ncurses-${NCURSES_VERSION} | |
./configure --prefix=$HOME/.local --enable-widec | |
make -j ${jobs} | |
make -j ${jobs} install | |
cd .. | |
############ | |
# tmux # | |
############ | |
echo -e "\n~~ tmux ~~" | |
tar xvzf tmux-${TMUX_VERSION}.tar.gz | |
cd tmux-${TMUX_VERSION} | |
CPPFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncursesw" LDFLAGS="-L$HOME/.local/lib" ./configure | |
CPPFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncursesw" LDFLAGS="-static -L$HOME/.local/lib" make -j ${jobs} | |
cp tmux $HOME/.local/bin | |
cd .. | |
############ | |
# htop # | |
############ | |
echo -e "\n~~ htop ~~" | |
tar xvzf htop-${HTOP_VERSION}.tar.gz | |
cd htop-${HTOP_VERSION} | |
CPPFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncursesw" LDFLAGS="-L$HOME/.local/lib" ./configure | |
CPPFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncursesw" LDFLAGS="-static -L$HOME/.local/lib" make -j ${jobs} | |
cp htop $HOME/.local/bin | |
cd .. | |
echo "$HOME/.local/bin/tmux and $HOME/.local/bin/htop is now available. You can optionally add $HOME/.local/bin to your PATH." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment