|
# 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' |