Files
dot-config-folder/tmux/tmux.conf
Jens Luedicke 47eb835345 Add newlines and remove trailing whitespace
* modified: git/hooks/pre-commit
* modified: tmux/tmux.conf
2025-09-30 10:30:39 +02:00

174 lines
6.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!"
# Screenshot bindings
bind C-s run-shell "tmux capture-pane -peS - > ~/tmux-screenshot-$(date +%Y%m%d-%H%M%S).txt && tmux display-message 'Screenshot saved to ~/tmux-screenshot-*.txt'"
bind C-S run-shell "tmux capture-pane -peS - -e | ansi2html > ~/tmux-screenshot-$(date +%Y%m%d-%H%M%S).html && tmux display-message 'HTML screenshot saved'"
# Enable vi mode in copy mode
setw -g mode-keys vi
# Enable word-wise jumping with Ctrl+Left/Right
bind -n C-Left send-keys M-b
bind -n C-Right send-keys M-f
# Enable word-wise selection with Ctrl+Shift+Left/Right
bind -n C-S-Left send-keys M-B
bind -n C-S-Right send-keys M-F
# 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-pipe-and-cancel "xclip -selection clipboard -i -r"
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i -r"
bind -T copy-mode-vi Escape send-keys -X cancel
# Strip trailing newlines when copying with mouse
set -s set-clipboard off
# Status bar customization - Root Loops themed
set -g status-position bottom
set -g status-style 'bg=#1a2137 fg=#acb8dc'
set -g status-left '#[fg=#050812,bg=#7f95db,bold] #S #[fg=#7f95db,bg=#1a2137]'
set -g status-right '#[fg=#424f7a,bg=#1a2137]#[fg=#acb8dc,bg=#424f7a] %d/%m #[fg=#66ab75,bg=#424f7a]#[fg=#050812,bg=#66ab75,bold] %H:%M '
set -g status-right-length 50
set -g status-left-length 30
# Window status - Root Loops themed
setw -g window-status-current-style 'fg=#050812 bg=#c877c1 bold'
setw -g window-status-current-format '#[fg=#1a2137,bg=#c877c1]#[fg=#050812] #I #W #[fg=#c877c1,bg=#1a2137]'
setw -g window-status-style 'fg=#acb8dc bg=#1a2137'
setw -g window-status-format ' #I #W '
setw -g window-status-separator ''
# Pane borders - Root Loops themed
set -g pane-border-style 'fg=#424f7a bg=#050812'
set -g pane-active-border-style 'fg=#7f95db bg=#050812'
# Messages - Root Loops themed
set -g message-style 'fg=#050812 bg=#b0964e bold'
set -g message-command-style 'fg=#050812 bg=#51a7b6'
# Mode colors (selection)
set -g mode-style 'fg=#050812 bg=#c877c1'
# Clock mode
set -g clock-mode-colour '#7f95db'
set -g clock-mode-style 24
# Copy mode colors
set -g copy-mode-match-style 'fg=#050812 bg=#d77c6e bold'
set -g copy-mode-current-match-style 'fg=#050812 bg=#66ab75 bold'
set -g copy-mode-mark-style 'fg=#050812 bg=#b0964e 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
# OLD FZF MENU (commented out to use exek launcher on Space)
# bind Space display-popup -E -w 80% -h 80% "bash ~/.config/tmux/tmux-fzf-menu.sh --menu"
# EXEK LAUNCHER - Fast TUI application launcher with fuzzy matching
# Launch with prefix + Space in a popup (replaces fzf menu)
bind Space display-popup -E -w 80% -h 60% '/usr/local/bin/exek'
# Alternative exek bindings:
# Launch in new window with prefix + o
bind o new-window -n launcher '/usr/local/bin/exek'
# Launch in popup with prefix + p (smaller size)
bind P display-popup -E -w 70% -h 50% '/usr/local/bin/exek'
# Quick launcher with Alt+Space (no prefix needed)
bind -n M-Space display-popup -E -w 80% -h 60% '/usr/local/bin/exek'
# Keep the original tmux-fzf-menu on prefix + M for tmux operations
bind M display-popup -E -w 80% -h 80% "bash ~/.config/tmux/tmux-fzf-menu.sh --menu"