Files
dotfiles/.tmux.conf
2025-05-26 07:39:19 +03:00

92 lines
2.7 KiB
Bash

# change default meta key to same as screen
unbind C-b
unbind C-a
set -g prefix C-a
# form vim/tmux d/y buffer sync
set -g focus-events
set -s escape-time 0
# use a different prefix for nested
bind-key -n C-y send-prefix
# add double-tap meta key to toggle last window
bind-key C-a last-window
# pane colors and display
# create more intuitive split key combos (same as modern screen)
# -c '#{pane_current_path}' ensures new split is in `pwd`
unbind |
bind | split-window -h -c '#{pane_current_path}'
bind '\' split-window -h -c '#{pane_current_path}'
bind 'C-\' split-window -h -c '#{pane_current_path}'
unbind -
bind - split-window -v -c '#{pane_current_path}'
unbind _
bind _ split-window -v -c '#{pane_current_path}'
# Fix colors being messed up with vim
set -ga terminal-overrides ",*256col*:Tc"
# vi for copy mode
setw -g mode-keys vi
# vi for command status
set -g status-keys vi
bind -r C-k resize-pane -U 1
# vi keys to resize
bind -r C-j resize-pane -D 1
bind -r C-h resize-pane -L 1
bind -r C-l resize-pane -R 1
# vi keys to navigate panes
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
bind q killp
bind x killw
# avoid cursor movement messing with resize
set -g repeat-time 200
# colors, clock, and stuff
set -g base-index 1
setw -g pane-base-index 1
# color of the window selection background
#set -g mode-style "bg=black"
#set -g status-style "bg=#202021,fg=#665c54"
set -g status-position bottom
set -g status-interval 1
set -g status-right ""
set -g status-left ""
#set -g status-right-style "fg=#928374"
set -g message-style "fg=red"
set -g status on
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
vim_pattern='(\\S+\\/)?g?\.?(view|l?n?vim?x?|fzf)(diff)?(-wrapped)?$'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +${vim_pattern}'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l