tmux

Install powerline, A fancy status line for tmux
sudo pip3 install --user --break-system-packages git+https://github.com/powerline/powerline
Copy powerline config files to a locally editable place
mkdir -p ~/.config/powerline
cp -r ~/.local/lib/python3.13/site-packages/powerline/config_files/* ~/.config/powerline
Now you can edit ~/.config/powerline/themes/tmux/default.json to customize your tmux status bar. For example I don’t want to see the system uptime or load in the status bar so I remove the sys.uptime and sys.system_load blocks.
I also edit ~/.config/powerline/config.json to enable term_truecolor.
Powerline fonts
In order to see some of the symbols that powerline uses you will need a supported font. I’ve found that the Hack powerline font is easy enough on the eyes. You’ll need to install it in macOS in order to use it with iTerm2 and you’ll need to install it in Windows in order to use it with PuTTY
Configure iTerm and PuTTY to use 256 colors and the new font
You’ll want to enable 256 color support otherwise you’ll be stuck using only 16 colors and that looks terrible.
For iTerm2 you’ll need to go to Settings -> Profiles -> Terminal and change “Report Terminal Type” to xterm-256color. Then go to Settings -> Profiles -> Text and change “Font” to Hack.
For PuTTY you’ll need to go to Configuration -> Connection -> Data and change “Terminal-type string” to putty-256color. Then go to Configuration -> Window -> Appearance -> Font settings and change “Font:” to Hack.
~/.config/tmux/tmux.conf
#
# mouse support
#
set -g mouse on
#
# prefix
#
unbind C-b # \
set-option -g prefix C-a # > Change prefix from `Ctrl-b` to `Ctrl-a`
bind-key C-a send-prefix # /
bind a send-prefix # Make it so `Ctrl-a a` mimics bash's ctrl-a (move cursor to beginning of line)
#
# sessions
#
bind C new-session # `Ctrl-a C` to create a new session
bind P switch-client -p # `Ctrl-a P` for previous session
bind N switch-client -n # `Ctrl-a N` for next session
bind S choose-tree # `Ctrl-a S` to bring up a choose session screen
set -g detach-on-destroy off # Go to previous session instead of detaching
#
# windows
#
unbind w
unbind &
unbind '"'
bind '"' choose-window # `Ctrl-a "` to bring up a choose window screen
bind A command-prompt -I "#W" "rename-window '%%'" # `Ctrl-a A` to name your current window
bind C-a last-window # `Ctrl-a Ctrl-a` to go to previous window
bind k confirm-before -p "kill window #W? (y/n)" kill-window # `Ctrl-a k` to kill (an unresponsive) window
set -g automatic-rename on # Automatically name your window (unless you've manually named it)
set -g history-limit 50000 # Window scrollback size
set -g renumber-windows off # Don't renumber windows if you close one
#
# panes
#
unbind %
bind | split-window -h # `Ctrl-a |` to split window vertically
bind - split-window -v # `Ctrl-a -` to split window horizontally
bind -n M-Left select-pane -L # `Alt-LeftArrow` to move to pane to the left
bind -n M-Right select-pane -R # `Alt-RightArrow` to move to pane to the right
bind -n M-Up select-pane -U # `Alt-UpArrow` to move to pane above
bind -n M-Down select-pane -D # `Alt-DownArrow` to move to pane below
bind s set-window-option synchronize-panes # `Ctrl-a s` to type in all panes at once
# Note, you can use `Ctrl-a z` to zoom into a pane (make the pane full screen). Also to zoom out.
#
# term
#
# Set tmux-256color for tmux for reasons: https://github.com/tmux/tmux/wiki/FAQ
set -g default-terminal "tmux-256color"
# Make sure true color capability "Tc" is set for xterm
set -ga terminal-overrides ",xterm*:Tc"
#
# powerline
#
source /lib/python3.10/site-packages/powerline/bindings/tmux/powerline.conf
Color test script
Here’s a script to make sure your terminal is working with true color. You may want to run this script both before and after running tmux to verify colors are working correctly. The end result should be a color bar that smoothly draws from read to blue. If it’s chunky or looks like blocks, True Color isn’t working.
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
s="/\\";
for (colnum = 0; colnum<term_cols; colnum++) {
r = 255-(colnum*255/term_cols);
g = (colnum*510/term_cols);
b = (colnum*255/term_cols);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'
Compiling tmux
I used to have to work on an old bastion host that was controlled by our security team and didn’t have sudo or root access. Which is odd, considering I had full root access to over 30,000 servers. It had an ancient version of tmux. The version of ncurses was so old that it didn’t come with the tmux-256color terminfo. It also didn’t have the libssl-dev package installed. Oddly enough, the server had gcc installed, so here’s how I was able to get the latest version of tmux installed into my home directory:
Make sure $HOME/.local exists
mkdir -p $HOME/.local
Setup some shell variables, add the following to your startup scripts (eg .bashrc or .zshrc)
export PATH=$HOME/.local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
export MANPATH=$HOME/.local/share/man:$MANPATH
Install pkg-config
wget https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
tar -xvf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure --prefix=$HOME/.local --with-internal-glib
make && make install
Install m4
wget https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz
tar -xvf m4-1.4.19.tar.xz
cd m4-1.4.19.tar.xz
./configure --prefix=$HOME/.local
make && make install
Install autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.xz
tar -xvf autoconf-2.72.tar.xz
cd autoconf-2.72
./configure --prefix=$HOME/.local
make && make install
Install automake
wget https://ftp.gnu.org/gnu/automake/automake-1.17.tar.xz
tar -xvf automake-1.17.tar.xz
cd automake-1.17
./configure --prefix=$HOME/.local
make && make install
Install ncurses
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz
tar -xvf ncurses-6.5.tar.gz
cd ncurses-6.5
./configure --prefix=$HOME/.local --with-shared --with-termlib --enable-pc-files --with-pkg-config-libdir=$HOME/.local/lib/pkgconfig
make && make install
Install libevent
wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
tar -xvf libevent-2.1.12-stable.tar.gz
cd libevent-2.1.12-stable
./configure --prefix=$HOME/.local --enable-shared --disable-openssl
make && make install
Install bison (yacc)
wget https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz
tar -xvf bison-3.8.2.tar.xz
cd bison-3.8.2
./configure --prefix=$HOME/.local
make && make install
Install tmux
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure --prefix=$HOME/.local
make && make install