Skip to content

Instantly share code, notes, and snippets.

@sverrejoh
Last active February 6, 2026 20:28
Show Gist options
  • Select an option

  • Save sverrejoh/42742b2522c9ce07900ac7e5a7a5f1ac to your computer and use it in GitHub Desktop.

Select an option

Save sverrejoh/42742b2522c9ce07900ac7e5a7a5f1ac to your computer and use it in GitHub Desktop.
tmux.conf — Tokyo Night theme, top status bar, Emacs copy mode, fzf session switcher

tmux.conf

My tmux config. Tokyo Night color scheme, top status bar with system stats, Emacs-style copy mode, and fzf session switching.

Prerequisites

  • tmux 3.3+
  • TPM (Tmux Plugin Manager)
  • fzf (for session switcher popup)
  • A Nerd Font (for status bar icons)

Install

# Install TPM (Tmux Plugin Manager) if you haven't already
git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm

# Copy config and scripts
mkdir -p ~/.config/tmux
cp tmux.conf ~/.config/tmux/tmux.conf
cp *.sh ~/.config/tmux/
chmod +x ~/.config/tmux/*.sh

# Start tmux and install plugins
tmux
# Press C-s I (capital I) to install plugins via TPM

Helper scripts

All scripts go in ~/.config/tmux/ and need chmod +x:

Script Purpose
mouse-indicator.sh Shows ON/OFF mouse mode in status bar
ram-usage.sh Displays RAM usage (used/total)
disk-usage.sh Displays disk usage for root partition
session-prev.sh Cycle to previous session by creation order
session-next.sh Cycle to next session by creation order
toggle-status.sh Toggle between full and minimal status bar

The tmux-cpu plugin handles CPU percentage automatically.

Key bindings

Key Action
C-s Prefix (replaces default C-b)
C-s C-s Send literal C-s to terminal
C-s r Reload config
C-s h/j/k/l Navigate panes (vim-style)
C-s | Split horizontally
C-s - Split vertically
C-s n/p Next/previous window (repeatable)
C-s (/) Previous/next session (repeatable)
C-s S fzf session switcher popup
C-s B Toggle status bar
C-s M Toggle mouse mode (for text selection on mobile)
C-s [ Enter copy mode (Emacs keys: C-space to select, Enter or M-w to copy)
#!/bin/sh
# Called by tmux status-left via #() - outputs mouse state icon
mouse=$(tmux show -gv mouse)
if [ "$mouse" = "on" ]; then
printf '\U000f037d'
else
printf '\U000f037e'
fi
# tmux.conf — Sverre Johansen
# Tokyo Night themed, top status bar, Emacs copy mode
# Requires: tpm, fzf, Nerd Fonts
# ─── General ────────────────────────────────────────────────────────
set -g prefix C-s # Prefix: C-s (easier than C-b)
set -g prefix2 None
unbind C-b
bind C-s send-prefix # C-s C-s sends literal C-s
bind r source-file ~/.config/tmux/tmux.conf # C-s r to reload config
set -g mouse on # Mouse support (scroll, resize, select pane)
set -g default-terminal "tmux-256color"
set -as terminal-features ',*:RGB' # True color support
set -gq allow-passthrough on # Allow escape sequence passthrough
set -g set-clipboard on # OSC 52 clipboard support
set -g history-limit 100000
set -sg escape-time 0 # No delay after Escape
set -g focus-events on
set -g display-time 2000
set -g repeat-time 1000 # Longer window for repeatable bindings
set -g base-index 0
setw -g pane-base-index 0
set -g renumber-windows on
set -g bell-action any
set -g monitor-bell on
# ─── Navigation ─────────────────────────────────────────────────────
# Vim-style pane selection
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Splits that preserve working directory
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Repeatable window cycling (C-s n n n / C-s p p p)
bind-key -r n next-window
bind-key -r p previous-window
# Repeatable session cycling by creation order
bind-key -r '(' run-shell "~/.config/tmux/session-prev.sh"
bind-key -r ')' run-shell "~/.config/tmux/session-next.sh"
# ─── Copy Mode (Emacs) ─────────────────────────────────────────────
set -g mode-keys emacs # C-s [ to enter, C-g to cancel
bind -T copy-mode Enter send -X copy-selection-and-cancel
# ─── Session Management ────────────────────────────────────────────
# fzf session switcher popup (C-s S), sorted by creation order
bind-key S display-popup -E \
"tmux list-sessions -F '#{session_created} #S' | sort -n | cut -d' ' -f2- \
| fzf --reverse \
| xargs -r tmux switch-client -t"
# Click session name in status bar to open tree view
bind-key -T root MouseDown1StatusLeft choose-tree -Zs
# ─── Toggles ───────────────────────────────────────────────────────
# Toggle mouse mode (C-s M) — disable to select text on iPad/mobile
bind M set -g mouse
# Toggle status bar (C-s B)
bind-key B run-shell "~/.config/tmux/toggle-status.sh"
# ─── Theme (Tokyo Night) ───────────────────────────────────────────
set-option -g status-position top
set -g status-style bg='#1a1b26',fg='#565f89'
set -g status-interval 2
set -g status-left-length 50
set -g status-right-length 400
# Status bar — left: session name + mouse indicator
set -g status-left '#[fg=#1a1b26,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1a1b26] #(~/.config/tmux/mouse-indicator.sh) '
# Status bar — right: cpu, ram, disk, hostname, clock (Nerd Font icons)
# Trailing spaces compensate for tmux miscounting icon width (1 space per icon in entire bar)
set -g status-right '#[fg=#9ece6a]󰻠 #{cpu_percentage} #[fg=#bb9af7]󰘚 #(~/.config/tmux/ram-usage.sh) #[fg=#ff9e64]󰋊 #(~/.config/tmux/disk-usage.sh) #[fg=#c0caf5]󰌢 #H #[fg=#7aa2f7]󰥔 %H:%M '
# Window tabs
set -g window-status-format '#[fg=#565f89] #I #W '
set -g window-status-current-format '#[fg=#7aa2f7]#[fg=#1a1b26,bg=#7aa2f7,bold] #I #W #[fg=#7aa2f7,bg=#1a1b26]'
set -g window-status-separator ''
# Pane borders
set -g pane-border-style fg='#3b4261'
set -g pane-active-border-style fg='#7aa2f7'
# Messages
set -g message-style bg='#7aa2f7',fg='#1a1b26'
set -g message-command-style bg='#292e42',fg='#7aa2f7'
# ─── Plugins (via TPM) ─────────────────────────────────────────────
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'omerxx/tmux-sessionx'
# Initialize TPM (keep at bottom, plugins may override settings)
run '~/.config/tmux/plugins/tpm/tpm'
#!/bin/bash
# Toggle between full and minimal status bar
FULL='#[fg=#9ece6a]󰻠 #(~/.config/tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh) #[fg=#bb9af7]󰘚 #(~/.config/tmux/ram-usage.sh) #[fg=#ff9e64]󰋊 #(~/.config/tmux/disk-usage.sh) #[fg=#c0caf5]󰌢 #H #[fg=#7aa2f7]󰥔 %H:%M '
MINI='#[fg=#565f89]󰁌 '
current=$(tmux show-option -gqv @status-mode)
if [ "$current" = "mini" ]; then
tmux set -g status-right "$FULL"
tmux set -g @status-mode "full"
else
tmux set -g status-right "$MINI"
tmux set -g @status-mode "mini"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment