# these are general settings for Tmux unrelated to Catppuccin
# Dependencies:
# + xclip
# ----------------------------=== Settings ===--------------------------
# --------=== General
# set -g default-terminal "screen-256color" # colors!
# set -g default-terminal "xterm-kitty" # colors!
# set -g default-terminal "xterm-256color" # colors!, DON't USE THIS generates problems with keyboard and other stuff
set -g default-terminal "tmux-256color"
# useful for fixing mismatching nvim colors while on Alacritty and other terminals. Follow: https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set -ag terminal-overrides ",xterm-256color:RGB"
# set-option -ga terminal-overrides ",tmux-256color:Tc"
setw -g xterm-keys on
set -s focus-events on
# faster command sequences aka no delay when pressing certain keys (e.g. Esc)
set -sg escape-time 0
set -sg repeat-time 400 # increase repeat timeout
# --------=== Other
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
set -g history-limit 50000
set -g mouse on
setw -q -g utf8 on # charset
# --------=== Display
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
set -g renumber-windows on # renumber windows when a window is closed
set -g set-titles on # set terminal title
set -g display-panes-time 800 # slightly longer pane indicators display time
set -g display-time 1000 # slightly longer status messages display time
set -g status-interval 0 # redraw status line every 10 seconds
# --------=== Activity
set -g monitor-activity on
set -g visual-activity off
# set -g bell-action none
# set -g visual-bell off
# set -g visual-silence off
# ----------------------------=== Key Bindings ===--------------------------
# see `man tmux`
# NOTE: -n: no prefix
# NOTE: -r: prefix not required after being pressed for `repeat-time`
set-option -g prefix M-f # change default tmux prefix from Ctrl+b to Alt+f
bind r source-file ~/.tmux.conf # source .tmux.conf at $HOME
bind-key v split-window -h -c "#{pane_current_path}" # horizontally split current window
bind-key s split-window -v -c "#{pane_current_path}" # vertically split current window
bind-key -r b set-option status # toggle statusline
bind-key g display-popup -E "tmux new-session -A -s scratch" # aka floating terminal
# thanks https://unix.stackexchange.com/a/525770
bind -n M-PageDown swap-window -d -t -1 # Move current window to the left and switch to it
bind -n M-PageUp swap-window -d -t +1 # Move current window to the right and switch to it
# bind -n C-S-Left swap-window -d -t -1
# bind -n C-S-Right swap-window -d -t +1
bind-key j choose-tree -swZ # TUI for moving around open windows
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
bind-key -n -r M-t new-window -c "#{pane_current_path}" # spawn a window in cwd
bind-key -n -r M-w kill-window # kill current window
bind-key -n -r M-c kill-pane # kill current pane
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
bind-key -n M-0 select-window -t 0
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' # use system clipboard
# bind-key -n M-S-Left resize-pane -D
# bind-key -n M-S-Right resize-pane -U
# bind-key -n M-S-Up resize-pane -L
# bind-key -n M-S-Down resize-pane -R
# Use Alt-arrow keys without the prefix to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# ----------------------------=== Modes ===--------------------------
set -g status-keys vi # vi status
setw -g mode-keys vi # vi shortcuts