Marvel at the multiplex

tmux serves as a "window manager" for the terminal. ~/.tmux.conf is a magical place for tweaking tmux to your liking. Mine began years ago on the careful advice of a friend with the remapping of caps-lock to Control. And maybe deep down I just want more control in life?

Configuration

These settings make sense to me both ergonomically and visually. With < and > as metaphors for left and right and | and - visually representing a horizontal and vertical line

# Set prefix to Ctrl-a, ergonomic when caps lock is set to Ctrl
set-option -g prefix C-a
bind-key a send-prefix

# Begin numbering at 1
set -g base-index 1

# Next/Previous session with ( )
bind-key 9 switch-client -p
bind-key 0 switch-client -n

# Tag sessions and windows with T t
bind-key T command-prompt -I "#S" "rename-session '%%'"
bind-key t command-prompt -I "#W" "rename-window '%%'"

# New window with n
bind-key n new-window -c "#{pane_current_path}"

# Next/Previous window with < >
bind-key , previous-window
bind-key . next-window

# Vertical/horizontal window split with | -
bind-key \\ split-window -h -c "#{pane_current_path}"
bind-key - split-window -c "#{pane_current_path}"

# Resize panes sans-prefix with Alt-arrow
bind-key -n M-Left resize-pane -L 5
bind-key -n M-Right resize-pane -R 5
bind-key -n M-Up resize-pane -U 5
bind-key -n M-Down resize-pane -D 5

# When closing a window we auto renumber
set-option -g renumber-windows on

# Allow mouse click to select pane
set -g mouse on

# Turn off auto rename!
set-window-option -g automatic-rename off
set-option -g allow-rename off

# Colors, status bar
set -g status-style fg=gray
set -g pane-active-border-style fg=gray
set-window-option -g window-status-current-style "fg=black,bg=gray"
set -g status-right '#[fg=gray] %a, %b %d #[fg=gray] %I:%M %p '

# Prevent session name truncation
set -g status-left-length 32

# Refresh every second
set -g status-interval 4
set -s escape-time 0

# Ensure zsh is used
set -g default-shell /bin/zsh

# Modal pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Support italics
set-option default-terminal "tmux-256color"

# Reload configuration with prefix r
bind-key r source-file ~/.tmux.conf \; display-message "config reloaded"

Scripting workspace start-up

When I get started with work I run ./dev.sh to get a preferred layout and open up my brain of notes. C-m is the return key to execute the command.

#!/bin/bash

sess="dev"
tmux new-session -d -s $sess

# Open brain-3
win=1
tmux rename-window -t $sess:$win '🧠'
tmux send-keys -t $sess:$win 'cd ~/brain-3 && hx .' C-m

# Open code in split
win=2
tmux new-window -t $sess:$win -n '⚡️'
tmux send-keys -t $sess:$win 'cd ~/code && clear' C-m
tmux split-window -h
tmux send-keys -t $sess:$win 'cd ~/code && clear' C-m

# launch the session
tmux attach -t $sess

Defaults

The defaults are listed in the tmux(1) manpage.

Thanks

Marvel at the multiplex
Interactive graph
On this page
Configuration
Scripting workspace start-up
Defaults
Thanks