tmux: Bugfixes and refactoring

This commit is contained in:
2026-02-13 09:14:07 +01:00
parent 3ef233942e
commit a9627f7f88

View File

@@ -1,125 +1,99 @@
### General Settings ### General Settings
# Enable mouse support in tmux # Mouse support
set -g mouse on set -g mouse on
# Set the default terminal type to "tmux-256color" for better color support # Terminal type
set -g default-terminal "tmux-256color" set -g default-terminal "tmux-256color"
# Set the base index for windows to 1 (instead of the default 0) # Window base index
set -g base-index 1 set -g base-index 1
# Set the base index for panes to 1 (instead of the default 0) # Pane base index
setw -g pane-base-index 1 setw -g pane-base-index 1
# Increase the history limit (useful for longer command histories) # History limit
set-option -g history-limit 10000 set-option -g history-limit 10000
### Startup Configuration ### Startup Configuration
# Start a new session named "main" if none exists # Ensure main session exists and setup startup layout
new-session -s main if-shell 'tmux has-session -t main 2>/dev/null' '' 'new-session -ds main; send-keys -t main:1 "htop" C-m; split-window -t main:1'
# Start htop and split the window when the session "main" is created
set-hook -t main session-created 'send-keys -t main:1 "sudo htop" C-m; split-window'
### Key Bindings ### Key Bindings
# Remap the prefix key from 'C-b' (Ctrl-b) to 'C-a' (Ctrl-a) # Prefix key
unbind C-b unbind C-b
set-option -g prefix C-a set-option -g prefix C-a
bind-key C-a send-prefix bind-key C-a send-prefix
# Split panes using 'h' for horizontal and 'v' for vertical splits # Pane splits
bind "h" split-window -h bind "h" split-window -h
bind "v" split-window -v bind "v" split-window -v
unbind '"' unbind '"'
unbind % unbind %
# Reload the tmux configuration file with 'r' # Reload config
bind r source-file $XDG_CONFIG_HOME/tmux/tmux.conf bind r source-file $XDG_CONFIG_HOME/tmux/tmux.conf \; display-message "tmux config reloaded"
### Clipboard Integration ### Clipboard Integration
# Enable clipboard # Clipboard
set -s set-clipboard on set -s set-clipboard on
set -ag terminal-overrides ",*:Ms=\\E]52;c;%p2%s\\7" set -ag terminal-overrides ",*:Ms=\\E]52;c;%p2%s\\7"
# Vi-style copy mode # Copy mode
setw -g mode-keys vi setw -g mode-keys vi
# Copy mode key bindings # Copy bindings
bind-key -T copy-mode-vi v send-keys -X begin-selection bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh" bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh" bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh" bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "$XDG_CONFIG_HOME/tmux/yank.sh"
### Status and Window Configuration ### Status and Window Configuration
# Set the status bar update interval to 1 second # Status interval
set -g status-interval 1 set -g status-interval 1
# Enable automatic renaming of windows # Auto rename
set-option -g automatic-rename on set-option -g automatic-rename on
# Set window title to the current directory if the process is zsh, otherwise show the process name with arguments # Rename format
set-option -g automatic-rename-format '#{?#{==:#{pane_current_command},zsh},#(echo #{pane_current_path} | sed "s|^$HOME|~|"),#{pane_current_command}}' set-option -g automatic-rename-format '#{?#{==:#{pane_current_command},zsh},#(echo #{pane_current_path} | sed "s|^$HOME|~|"),#{pane_current_command}}'
# Set the color of the clock mode # Clock color
set -g clock-mode-colour "#8bd5ca" set -g clock-mode-colour "#8bd5ca"
# Set the style for copy mode (foreground black, background a specific color, bold text) # Copy mode style
set -g mode-style 'fg=black bg=#ed8796 bold' set -g mode-style 'fg=black bg=#ed8796 bold'
# Set the style for pane borders # Pane borders
set -g pane-border-style 'fg=white' set -g pane-border-style 'fg=white'
set -g pane-active-border-style 'fg=#8bd5ca' set -g pane-active-border-style 'fg=#8bd5ca'
### Status Bar Configuration ### Status Bar Configuration
# Position the status bar at the bottom # Status position
set -g status-position bottom set -g status-position bottom
# Align status bar items to the left # Status justify
set -g status-justify left set -g status-justify left
# Set the style for the status bar # Status style
set -g status-style 'fg=white,bg=#262626' set -g status-style 'fg=white,bg=#262626'
# Clear the default left status # Clear status left
set -g status-left '' set -g status-left ''
# Set the maximum length for the left status # Status left length
set -g status-left-length 30 set -g status-left-length 30
# ## Session name in the status bar # Session and prefix
# set -ga status-left "#[bg=#444444,fg=white] #S " set -ga status-left '#[fg=#cad3f5,bg=#1e1e2e] #S #[fg=#{?client_prefix,#f38ba8,#585b70}]● '
# # Display different colors for the session name based on whether the prefix is active
# set -ga status-left '#[fg=black]#{?client_prefix,#[bg=#ed8796] S ,#[bg=#a6da95] S }'
# set -ga status-left '#[bg=#262626] '
# # Set window status format to include the current directory or command
# setw -g window-status-format '#[bg=#8787AF,fg=black] #I #[bg=#585B70,fg=white] #W #F '
# # Set the current window status format to include the current directory or command
# setw -g window-status-current-format '#[bg=#c6a0f6,fg=black] #I #[bg=#585B70,fg=white] #W #F '
# # Set the separator between window statuses
# set -g window-status-separator " "
# # Status bar right settings (display host information)
# set -g status-right "#[fg=black,bg=#7dc4e4] H #[fg=white,bg=brightblack] #H "
# # Set the maximum length for the right status
# set -g status-right-length 40
# Session name and prefix indicator (space always reserved to prevent content shift)
set -ga status-left '#[fg=#cdd6f4,bg=#313244] #S #[fg=#{?client_prefix,#f38ba8,#585b70}]● #[fg=#cdd6f4,bg=#1e1e2e] '
# Window tabs # Window tabs
setw -g window-status-format '#[fg=#cdd6f4,bg=#313244] #I: #W #[fg=#cdd6f4,bg=#1e1e2e] ' setw -g window-status-format '#[fg=#cdd6f4,bg=#313244] #I: #W #[fg=#cdd6f4,bg=#1e1e2e] '
setw -g window-status-current-format '#[fg=#1e1e2e,bg=#cba6f7,bold] #I: #W #[fg=#cdd6f4,bg=#1e1e2e,nobold] ' setw -g window-status-current-format '#[fg=#1e1e2e,bg=#cba6f7,bold] #I: #W #[fg=#cdd6f4,bg=#1e1e2e,nobold] '
# Set the separator between window statuses # Window separator
set -g window-status-separator '' set -g window-status-separator ''
# Status bar right (H local / SSH remote) # Status right
set -g status-right '' set -g status-right ''
set -g status-right-length 50 set -g status-right-length 50
set -ga status-right '#{?SSH_CONNECTION,#[fg=#1e1e2e#,bg=#fab387#,bold] SSH #[fg=#cdd6f4#,bg=#1e1e2e#,nobold] ,}' set -ga status-right '#{?SSH_CONNECTION,#[fg=#1e1e2e#,bg=#fab387#,bold] SSH #[fg=#cdd6f4#,bg=#1e1e2e#,nobold] ,}'