Files
dotfiles/.tmux.conf
T
2026-07-21 20:29:28 +02:00

121 lines
5.3 KiB
Bash

# ~/.tmux.conf — Vim-centric tmux configuration (tmux 3.7+)
# Reload with: prefix + r
# --- Terminal and responsiveness ---------------------------------------------
set -g default-terminal "tmux-256color"
set -as terminal-features ",xterm-256color:RGB,screen-256color:RGB,tmux-256color:RGB"
set -sg escape-time 10
set -sg repeat-time 600
set -s focus-events on
set -g allow-passthrough on
set -g history-limit 100000
set -g set-clipboard on
# --- Prefix and defaults ------------------------------------------------------
unbind C-b
set -g prefix C-a
bind C-a send-prefix
setw -g mode-keys vi
set -g status-keys vi
set -g mouse on
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g detach-on-destroy off
set -g display-panes-time 800
set -g display-time 1500
# --- Reload and editing -------------------------------------------------------
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded"
bind e new-window -n tmux.conf "exec \${EDITOR:-nvim} ~/.tmux.conf"
# --- Vim-style panes ----------------------------------------------------------
# Keep the familiar split keys and always inherit the active pane's directory.
bind m split-window -v -c "#{pane_current_path}"
bind n split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Re-tile the current window using Ctrl-a, Ctrl-h / Ctrl-a, Ctrl-k.
bind C-h select-layout even-vertical
bind C-k select-layout even-horizontal
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind -r \{ swap-pane -U
bind -r \} swap-pane -D
bind z resize-pane -Z
bind w confirm-before -p "kill pane #P? (y/n)" kill-pane
# --- Windows, sessions, and buffers ------------------------------------------
bind -r f next-window
bind -r b previous-window
bind Tab last-window
bind d choose-tree -Zw
bind s choose-tree -Zs
bind g command-prompt -p "switch to session:" "switch-client -t '%%'"
bind [ choose-buffer
bind P paste-buffer # tmux buffer fallback; prefix + ] pastes the system clipboard
bind C-l send-keys C-l \; clear-history
# --- Copy mode ----------------------------------------------------------------
bind Enter copy-mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi q send -X cancel
bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line
bind -T copy-mode-vi C-u send -X halfpage-up
bind -T copy-mode-vi C-d send -X halfpage-down
# Keep tmux and the desktop clipboard in sync by default. `set-clipboard on`
# handles OSC 52-capable terminals; these bindings cover local Wayland/X11.
# Copy-mode y writes to the system clipboard. Prefix + ] reads it back and
# pastes it; prefix + P remains available for the most recent tmux buffer.
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'if command -v wl-copy >/dev/null 2>&1; then wl-copy; elif command -v xclip >/dev/null 2>&1; then xclip -in -selection clipboard; fi'
bind ] run-shell 'if command -v wl-paste >/dev/null 2>&1; then wl-paste --no-newline | tmux load-buffer - && tmux paste-buffer; elif command -v xclip >/dev/null 2>&1; then xclip -out -selection clipboard | tmux load-buffer - && tmux paste-buffer; fi'
# --- Status line --------------------------------------------------------------
set -g status on
set -g status-position bottom
set -g status-interval 5
set -g status-justify left
set -g status-left-length 40
set -g status-right-length 100
# Noctalia "Ember OLED" palette: deep near-black with restrained amber focus.
set -g status-style "bg=#050403,fg=#fff1e6"
set -g message-style "bg=#ff8800,fg=#1a0d00"
set -g message-command-style "bg=#ff8800,fg=#1a0d00"
set -g pane-border-style "fg=#6e4a31"
set -g pane-active-border-style "fg=#ff8800"
set -g mode-style "bg=#ffb05c,fg=#2b1600"
# The left segment switches to a large amber cue while tmux waits for the
# key following C-a, so prefix mode is visible rather than implicit.
# Keep each style attribute in its own sequence: conditional-format commas then
# cannot be mistaken for part of a #[fg=…,bg=…] style specification.
set -g status-left "#{?client_prefix,#[bg=#ffb05c]#[fg=#2b1600]#[bold] C-a COMMAND ,#[bg=#ff8800]#[fg=#1a0d00]#[bold] #S }#[bg=#050403]#[fg=#ff8800]"
set -g status-right "#[fg=#f4c7a1]#(whoami)@#H #[fg=#ff8800]| #[fg=#fff1e6]%Y-%m-%d %H:%M "
setw -g window-status-format " #[fg=#f4c7a1]#I:#W "
setw -g window-status-current-format "#[bg=#1a110c,fg=#fff1e6,bold] #I:#W "
# --- Optional TPM plugins -----------------------------------------------------
# Install TPM once: git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Then reload and press prefix + I to install these plugins.
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-continuum'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
if-shell '[ -f ~/.tmux/plugins/tpm/tpm ]' 'run ~/.tmux/plugins/tpm/tpm'
# Keep machine-specific bindings and experiments out of this tracked base file.
if-shell '[ -f ~/.tmux.conf.local ]' 'source-file ~/.tmux.conf.local'