Skip to content

Instantly share code, notes, and snippets.

@octavifs
Last active March 12, 2024 16:02
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save octavifs/45e120c7abe9bf03c652f70260947344 to your computer and use it in GitHub Desktop.
Save octavifs/45e120c7abe9bf03c652f70260947344 to your computer and use it in GitHub Desktop.
Install tmux and htop statically without root
#!/bin/sh
# Script for installing tmux & htop on systems where you don't have root access.
# Inspired by https://gist.github.com/ryin/3106801
# tmux will be installed in $HOME/local/bin.
# htop will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_URL=https://github.com/tmux/tmux/releases/download/3.1b/tmux-3.1b.tar.gz
HTOP_URL=https://hisham.hm/htop/releases/2.0.2/htop-2.0.2.tar.gz
LIBEVENT_URL=https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
NCURSES_URL=ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz
# create our directories
mkdir -p $HOME/local $HOME/tmux_htop_tmp
cd $HOME/tmux_htop_tmp
# download source files for tmux, libevent, and ncurses
wget $TMUX_URL -O tmux.tar.gz
wget $HTOP_URL -O htop.tar.gz
wget $LIBEVENT_URL -O libevent.tar.gz
wget $NCURSES_URL -O ncurses.tar.gz
# extract files, configure, and compile
############
# libevent #
############
mkdir -p $HOME/tmux_htop_tmp/libevent
tar xvzf libevent.tar.gz -C $HOME/tmux_htop_tmp/libevent --strip-components=1
cd libevent
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..
############
# ncurses #
############
mkdir -p $HOME/tmux_htop_tmp/ncurses
tar xvzf ncurses.tar.gz -C $HOME/tmux_htop_tmp/ncurses --strip-components=1
cd ncurses
./configure --prefix=$HOME/local
make
make install
cd ..
############
# tmux #
############
mkdir -p $HOME/tmux_htop_tmp/tmux
tar xvzf tmux.tar.gz -C $HOME/tmux_htop_tmp/tmux --strip-components=1
cd tmux
./configure CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include"
CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib" make
cp tmux $HOME/local/bin
cd ..
############
# htop #
############
mkdir -p $HOME/tmux_htop_tmp/htop
tar xvzf htop.tar.gz -C $HOME/tmux_htop_tmp/htop --strip-components=1
cd htop
./configure --disable-unicode CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include"
CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib" make
cp htop $HOME/local/bin
cd ..
# cleanup
rm -rf $HOME/tmux_htop_tmp
echo "$HOME/local/bin/tmux is now available. You can optionally add $HOME/local/bin to your PATH."
echo "$HOME/local/bin/htop is now available. You can optionally add $HOME/local/bin to your PATH."
@npetitclerc
Copy link

Worked great for me, but the link to download htop is broken. Here's the latest one: https://bintray.com/htop/source/download_file?file_path=htop-3.0.2.tar.gz

Source: https://bintray.com/htop/source/htop#files

@octavifs
Copy link
Author

octavifs commented Oct 27, 2020 via email

@eduamf
Copy link

eduamf commented Apr 12, 2022

Worked great for me, but the link to download htop is broken. Here's the latest one: https://bintray.com/htop/source/download_file?file_path=htop-3.0.2.tar.gz

Source: https://bintray.com/htop/source/htop#files

I think it was not changed! But the previous link changed to HTOP_URL=https://github.com/htop-dev/htop/releases/download/3.1.2/htop-3.1.2.tar.xz

First error (with warning) ...

evdns.c: In function ‘evdns_request_transmit’:
evdns.c:2269:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
   retcode = 1;
   ~~~~~~~~^~~

Second one:

...
 undefined reference to `COLS'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:716: htop] Error 1
make[1]: Leaving directory '/cfs/home/eamf/tmux_htop_tmp/htop'
make: *** [Makefile:522: all] Error 2
(base) eamf@xxx:~/tmux_htop_tmp/htop> cp htop $HOME/local/bin
cp: cannot stat 'htop': No such file or directory

@nammingi
Copy link

It worked great.

To improve usability, I think it will be good when below line added.

echo $HOME/.bashrc << export PATH="$PATH/local/bin"

Thank you.

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