134 lines
5.5 KiB
Bash
134 lines
5.5 KiB
Bash
# For some reason, fzf is missing from path when running shell scripts through tmux keybindings
|
|
set-environment -g PATH "~/dev/git/fzf/bin:$PATH"
|
|
|
|
# Keybindings for navigating between panes
|
|
bind-key -n M-Left select-pane -L
|
|
bind-key -n M-Down select-pane -D
|
|
bind-key -n M-Up select-pane -U
|
|
bind-key -n M-Right select-pane -R
|
|
bind-key -n M-h select-pane -L
|
|
bind-key -n M-j select-pane -D
|
|
bind-key -n M-k select-pane -U
|
|
bind-key -n M-l select-pane -R
|
|
|
|
# Resize mode
|
|
set -g @tmux_resize_mode 0
|
|
set -g @resize_mode_path "~/.config/tmux/tmux-set-resize-mode.sh"
|
|
bind-key -n M-Space if-shell -F "#{==:#{@tmux_resize_mode},0}" "run-shell '#{@resize_mode_path} 1'" ""
|
|
bind-key -n Escape if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys Escape"
|
|
bind-key -n Enter if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys Enter"
|
|
bind-key -n q if-shell -F "#{==:#{@tmux_resize_mode},1}" "run-shell '#{@resize_mode_path} 0'" "send-keys q"
|
|
|
|
# Resize the panes if we are in resize mode
|
|
bind-key -n Up if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -U" "send-keys Up"
|
|
bind-key -n Down if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -D" "send-keys Down"
|
|
bind-key -n Left if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -L" "send-keys Left"
|
|
bind-key -n Right if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -R" "send-keys Right"
|
|
bind-key -n k if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -U" "send-keys k"
|
|
bind-key -n j if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -D" "send-keys j"
|
|
bind-key -n h if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -L" "send-keys h"
|
|
bind-key -n l if -F "#{==:#{@tmux_resize_mode},1}" "resize-pane -R" "send-keys l"
|
|
|
|
bind-key -n M-p display-message "#{@tmux_resize_mode}"
|
|
|
|
bind-key -n M-d run-shell "~/.config/tmux/tmux-fuzzy-find-session.sh"
|
|
|
|
# Split window, change keybindings to match vim concept of splits
|
|
bind-key -n M-V split-window -h -c "#{pane_current_path}"
|
|
bind-key -n M-S split-window -v -c "#{pane_current_path}"
|
|
bind-key -n M-q kill-pane
|
|
bind-key -n M-F resize-pane -Z
|
|
bind-key -n M-s command-prompt -p "New session: " "run-shell '~/.config/tmux/tmux-create-session.sh '%%''"
|
|
bind-key -n M-w new-window -c "#{pane_current_path}"
|
|
bind-key -n M-r command-prompt -p "Rename session:" "rename-session '%%'"
|
|
|
|
bind-key -n M-c copy-mode
|
|
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
|
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
|
|
bind-key -n M-0 select-window -t 0
|
|
bind-key -n M-1 select-window -t 1
|
|
bind-key -n M-2 select-window -t 2
|
|
bind-key -n M-3 select-window -t 3
|
|
bind-key -n M-4 select-window -t 4
|
|
bind-key -n M-5 select-window -t 5
|
|
bind-key -n M-6 select-window -t 6
|
|
bind-key -n M-7 select-window -t 7
|
|
bind-key -n M-8 select-window -t 8
|
|
bind-key -n M-9 select-window -t 9
|
|
|
|
set -g @move-pane-path "~/.config/tmux/tmux-move-pane.sh"
|
|
bind-key -n M-) run-shell "#{@move-pane-path} 0"
|
|
bind-key -n M-! run-shell "#{@move-pane-path} 1"
|
|
bind-key -n M-@ run-shell "#{@move-pane-path} 2"
|
|
bind-key -n M-# run-shell "#{@move-pane-path} 3"
|
|
bind-key -n M-$ run-shell "#{@move-pane-path} 4"
|
|
bind-key -n M-% run-shell "#{@move-pane-path} 5"
|
|
bind-key -n M-^ run-shell "#{@move-pane-path} 6"
|
|
bind-key -n M-& run-shell "#{@move-pane-path} 7"
|
|
bind-key -n M-* run-shell "#{@move-pane-path} 8"
|
|
bind-key -n M-( run-shell "#{@move-pane-path} 9"
|
|
|
|
# Reload tmux configuration
|
|
bind-key -n M-C source-file ~/.tmux.conf \; display-message "Config reloaded"
|
|
|
|
# Set the default terminal to support 256 colors
|
|
set -g default-terminal "tmux-256color"
|
|
|
|
# Enable true color support in tmux
|
|
set-option -ga terminal-features ',xterm-ghostty:RGB'
|
|
set-option -ga terminal-features ',xterm-256color:RGB'
|
|
set-option -ga terminal-features ',tmux-256color:RGB'
|
|
|
|
# Ensure tmux recognizes terminal overrides for true color
|
|
set-option -ga terminal-overrides ',xterm-ghostty:Tc'
|
|
set-option -ga terminal-overrides ',xterm-256color:Tc'
|
|
set-option -ga terminal-overrides ',*:Tc'
|
|
|
|
# Specific overrides for underline and underline colors (requires tmux >= 3.0)
|
|
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
|
|
set -as terminal-overrides ',*:Setulc=\E[58::2::::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
|
|
|
|
# Make sure that the index of windows and panes starts at 1
|
|
set -g base-index 1
|
|
set -g pane-base-index 1
|
|
set -g renumber-windows on
|
|
|
|
set -g mode-keys vi
|
|
|
|
set-option -g status-position top
|
|
|
|
# Address vim mode switching delay (http://superuser.com/a/252717/65504)
|
|
set -s escape-time 0
|
|
|
|
# Increase scrollback buffer size from 2000 to 50000 lines
|
|
set -g history-limit 50000
|
|
|
|
# Increase tmux messages display duration from 750ms to 4s
|
|
set -g display-time 2500
|
|
|
|
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
|
|
set -g status-interval 2
|
|
|
|
# Focus events enabled for terminals that support them
|
|
set -g focus-events on
|
|
|
|
# Super useful when using "grouped sessions" and multi-monitor setup
|
|
setw -g aggressive-resize on
|
|
|
|
# Set the left status: Tabs (window names)
|
|
set -g status-left ""
|
|
setw -g automatic-rename off
|
|
set-hook -g after-new-window "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
|
|
set-hook -g pane-focus-in "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
|
|
|
|
# Set the right status: Battery, date and time, session name
|
|
set -g status-right "#($HOME/.config/tmux/tmux-status-right.sh)"
|
|
run-shell '~/.config/tmux/tmux-statusbar-color.sh'
|
|
|
|
set -g status-style bold
|
|
|
|
# SSH agent forwarding
|
|
set-option -g update-environment "SSH_AUTH_SOCK SSH_CONNECTION"
|
|
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
|
|
set -g @plugin "tmux-plugins/tpm"
|
|
run "~/dev/git/tpm/tpm"
|