Files
dot-config-folder/tmux/tmux.conf
Jens Luedicke 8e563fec51 Add session manager for tmux.
This will open a tmux session for each monitor.
Add helper script for tmux actions.
2025-09-22 15:26:42 +02:00

126 lines
4.2 KiB
Bash

# Set prefix to Ctrl-a (easier to reach than Ctrl-b)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support
set -g mouse on
# Set base index to 1 (instead of 0)
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closed
set -g renumber-windows on
# Increase scrollback buffer size
set -g history-limit 50000
# Set default shell to zsh
set-option -g default-shell /usr/bin/zsh
# Enable 256 colors and true color support
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Faster key repetition
set -s escape-time 0
# Split panes using v and b (or \ and -)
bind v split-window -h -c "#{pane_current_path}"
bind b split-window -v -c "#{pane_current_path}"
bind '\' split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Easy pane navigation with vim-like keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes with vim-like keys
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
# Easy window navigation
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Reload config file
bind r source-file ~/.config/tmux/tmux.conf \; display "Config reloaded!"
# Enable vi mode in copy mode
setw -g mode-keys vi
# Copy mode bindings
bind Enter copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send-keys -X cancel
# Status bar customization
set -g status-position bottom
set -g status-style 'bg=colour235 fg=colour137'
set -g status-left '#[fg=colour233,bg=colour245,bold] #S '
set -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20
# Window status
setw -g window-status-current-style 'fg=colour81 bg=colour238 bold'
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-style 'fg=colour138 bg=colour235'
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
# Pane borders
set -g pane-border-style 'fg=colour238'
set -g pane-active-border-style 'fg=colour51'
# Messages
set -g message-style 'fg=colour232 bg=colour166 bold'
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity off
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Focus events (for vim integration)
set -g focus-events on
# Keep current path when creating new windows
bind c new-window -c "#{pane_current_path}"
# FZF integration
# Session switcher
bind s display-popup -E "tmux list-sessions -F '#{session_name}' | fzf --preview 'tmux list-windows -t {} | column -t' --preview-window=down:20% | xargs tmux switch-client -t"
# Window switcher
bind w display-popup -E "tmux list-windows -F '#{window_index}: #{window_name}' | fzf --preview 'tmux list-panes -t {1} -F \"#{pane_index}: #{pane_current_command}\"' | cut -d: -f1 | xargs tmux select-window -t"
# Quick file search and open in new window
bind f display-popup -E "fd --type f --hidden --follow --exclude .git | fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}' | xargs -I {} tmux new-window 'vim {}'"
# Quick directory navigation
bind g display-popup -E "fd --type d --hidden --follow --exclude .git | fzf --preview 'tree -C {} | head -200' | xargs -I {} tmux send-keys 'cd {}' Enter"
# Move window to another session with fzf
bind m display-popup -E "bash ~/.config/tmux/move-window.sh"
# Swap windows with fzf
bind M display-popup -E "tmux list-windows -F '#{window_index}: #{window_name}' | fzf --header='Swap current window with:' | cut -d: -f1 | xargs -I {} tmux swap-window -t {}"
# Move pane to another window with fzf
bind p display-popup -E "tmux list-windows -F '#{window_index}: #{window_name}' | fzf --header='Move pane to window:' | cut -d: -f1 | xargs -I {} tmux join-pane -t :{}"
# Break pane into new window
bind B break-pane -d
# Comprehensive tmux operations menu with fzf
bind Space display-popup -E -w 80% -h 80% "bash ~/.config/tmux/tmux-fzf-menu.sh --menu"