# better prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# remove escape delay
set -sg escape-time 0

# better splitting
bind v split-window -h
bind x split-window -v
unbind '"'
unbind %

# navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# resizing
bind + resize-pane -D 5
bind - resize-pane -U 5
bind < resize-pane -L 5
bind > resize-pane -R 5

# swap panes around
bind-key -r J swap-pane -D
bind-key -r K swap-pane -U

# reload config
bind r source-file ~/.tmux.conf

# sessions
bind-key S choose-session -Z

# window and pane indices
set -g base-index 1
setw -g pane-base-index 1

# Terminal stuff
set -g default-terminal "tmux-256color"
set-option -sa terminal-overrides ',xterm*:Tc'
set-option -sa terminal-features ",xterm-256color:RGB"
set -g allow-passthrough on

set-option -g focus-events on

# loud or quiet?
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none

set -g mouse on
set -s set-clipboard on

# monitor window changes
set-option -wg monitor-activity on
set-option -wg monitor-bell on

# set statusbar update interval
# set-option -g status-interval 1

### status bar
# default statusbar colors
set -g status-style "fg=white, bg=default, bright"

set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left-length 40
set -g status-right-length 140
set -g status-left '#[fg=blue]#h #[fg=gray]• #[fg=cyan]#S #[fg=black]'
set -g status-right '#[fg=gray] %H:%M %Y-%m-%d'

## Window list
# default window title colors
set-window-option -g window-status-style "fg=gray,dim bg=default"
set-window-option -g window-status-format "#I #W"
# active window title colors
set-window-option -g window-status-current-style "fg=white,bold bg=default"
set-window-option -g window-status-current-format "#I #W"
# window with new visual-activity
set-window-option -g window-status-activity-style "fg=cyan,bright bg=default"
# window list separators
set -g window-status-separator "#[fg=gray] | #[default]"

# command prompt
set -g message-style "fg=white,bright,bold"
set -g message-command-style "fg=red bg=default"

# pane borders
set -g pane-border-style "fg=black,bright bg=default"
set -g pane-active-border-style "fg=green"

# Support undercurl
set -sa terminal-overrides ',*:Smulx=\E[4::%p1%dm'
# Support colors for undercurl
set -sa terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'

# tpm itself is installed and updated by chezmoi
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'

if-shell 'command -v /usr/bin/fish' {
  set -g default-command '/usr/bin/fish'
  set -g default-shell '/usr/bin/fish'
}

run '~/.tmux/plugins/tpm/tpm'