Skip to main content

Overview

Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions, windows, and panes within a single terminal window. This configuration includes vi-mode keybindings, custom plugins, and a TokyoNight theme.

Configuration

The main configuration is located at .config/tmux/tmux.conf.

Basic settings

set-option -sa terminal-overrides ",xterm*:Tc"
set -sg escape-time 0
set -g mouse on

True color

Terminal override enables 24-bit true color support

Escape time

Zero escape time for instant key response

Mouse support

Mouse mode enabled for clicking and scrolling

Vi mode

Vi-style keybindings for copy mode

Prefix key

The prefix is changed from the default Ctrl+b to Ctrl+a:
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
Ctrl+a is easier to reach and commonly used in screen and other terminal multiplexers.

Window and pane indexing

Windows and panes start at 1 instead of 0 for easier keyboard access:
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
Windows are automatically renumbered when one is closed, keeping the sequence continuous.

Vi mode keybindings

Copy mode uses vi-style keybindings:
set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
Press v in copy mode to begin selection, just like in Vim:
bind -T copy-mode-vi v send-keys -X begin-selection
Press y to copy the selection to the system clipboard using xclip:
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

Status bar

The status bar is positioned at the top:
# Set the bar to the top
set -g status-position top

Image passthrough

Image passthrough is enabled for displaying images in the terminal:
# Allow Image passthrough
set -gq allow-passthrough on
set -g visual-activity off

Plugins

Tmux Plugin Manager (TPM) is used to manage plugins:
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin "j4ytr1n1ty/tokyo-night-tmux"
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'

tpm

Tmux Plugin Manager for easy plugin installation

vim-tmux-navigator

Seamless navigation between vim and tmux panes

tokyo-night-tmux

TokyoNight theme for tmux status bar

tmux-yank

Enhanced clipboard integration

tmux-resurrect

Save and restore tmux sessions

tmux-sensible

Sensible default settings for tmux

Tmux Resurrect configuration

Tmux Resurrect is configured to save Neovim sessions and pane contents:
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
This allows you to save and restore your entire tmux environment, including running programs and pane layouts.

TokyoNight theme settings

set -g @tokyo-night-tmux_theme dark    # dark | storm | day | default to 'night'
set -g @tokyo-night-tmux_show_path 0
set -g @tokyo-night-tmux_path_format relative # 'relative' or 'full'
set -g @tokyo-night-tmux_transparent 0  # 1 or 0
set -g @tokyo-night-tmux_show_music 0

Custom keybindings

Pane navigation

Vim-style pane navigation:
# vim-like pane switching
bind -r ^ last-window
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R

Split windows

Split windows open in the current pane’s directory:
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
New windows and panes automatically inherit the current working directory, saving you from having to navigate to the same location.

Tmux cheat sheet script

A custom keybinding opens an interactive cheat sheet using cht.sh:
# Custom Bindings
bind-key -r C run-shell "tmux neww ~/scripts/tmux/tmux-ch.sh"

tmux-ch.sh script

The script (scripts/tmux/tmux-ch.sh) provides quick access to programming language and command cheat sheets:
#!/usr/bin/env bash
selected=`cat ~/.tmux/.tmux-cht-languages ~/.tmux/.tmux-cht-command | fzf`
if [[ -z $selected ]]; then
    exit 0
fi

read -p "Enter Query: " query

if grep -qs "$selected" ~/.tmux-cht-languages; then
    query=`echo $query | tr ' ' '+'`
    tmux neww bash -c "echo \"curl cht.sh/$selected/$query/\" & curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done"
else
    tmux neww bash -c "curl -s cht.sh/$selected~$query | less -R"
fi
Press prefix + C to open an fzf menu of languages and commands. Select one, enter your query, and instantly get documentation from cht.sh.

Plugin installation

The TPM plugin manager is loaded at the end:
run '$HOME/.tmux/plugins/tpm/tpm'

Installation

  1. Install tmux and dependencies:
# Install tmux
sudo apt install tmux  # Debian/Ubuntu
brew install tmux      # macOS

# Install TPM
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
  1. Symlink the configuration:
stow -t ~ tmux
  1. Install plugins:
  • Start tmux
  • Press prefix + I (capital i) to install plugins
After installation, reload the configuration with prefix + r or restart tmux.

Quick reference

  • Ctrl+a: Prefix key
  • prefix + c: Create new window
  • prefix + ": Split horizontally
  • prefix + %: Split vertically
  • prefix + h/j/k/l: Navigate panes (vim-style)
  • prefix + C: Open cheat sheet
  • prefix + [: Enter copy mode
  • prefix + I: Install plugins
  • prefix + [: Enter copy mode
  • v: Begin selection
  • y: Copy selection to clipboard
  • q: Exit copy mode
  • prefix + Ctrl+s: Save session (tmux-resurrect)
  • prefix + Ctrl+r: Restore session (tmux-resurrect)

Build docs developers (and LLMs) love