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
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
# Start windows and panes at 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
# Don't exit tmux if another session exists, instead attach to that session
set-option -g detach-on-destroy off
# split panes using '|' and '-', because '"' and '%' suck
unbind '"'
unbind %
bind | split-window -h
bind - split-window -v
# switch panes using Alt-arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Enable mouse. Select active pane, adjust pane size, scrollling in windows and panes
set -g mouse on
# bring cursor to beginning of line like in screen: C-a, a
bind a send-prefix
# bind 'C' to create a new session, P to previous session, N to next
bind C new-session
bind P switch-client -p
bind N switch-client -n
# bind '"' to choose-window, instead of 'w', similar to screen
unbind w
bind '"' choose-window
# bind 'A' to rename-window, similar to screen
bind A command-prompt -I "#W" "rename-window '%%'"
# bind C-a, C-a to previous window
bind C-a last-window
# bind 'k' to kill-window (instead of &)
unbind &
bind k confirm-before -p "kill window #W? (y/n)" kill-window
# Clear tmux history
bind -n C-k clear-history
# bind 's' to synchronize typing in panes
# rebind 's' choose-tree to 'S'
bind S choose-tree
bind s set-window-option synchronize-panes
# rename window to reflect current program
# will not rename windows that have been manually named
setw -g automatic-rename on
# Use appropriate term inside tmux https://github.com/tmux/tmux/wiki/FAQ
set -g default-terminal "tmux-256color"
# True color in tmux
set -ga terminal-overrides ",xterm*:Tc"
# increase scrollback buffer size
set -g history-limit 10000
# set shell
set -g default-shell /bin/zsh
# Remove SSH_AUTH_SOCK to disable tmux automatically resetting the variable
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
# Use a symlink to look up SSH authentication
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
# for neovim
set-option -sg escape-time 10
set-option -g focus-events on
set -g set-clipboard on
# powerline
source /lib/python3.13/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