# Set the prefix to `ctrl + a` instead of `ctrl + b`
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

# Use | and - to split a window vertically and horizontally instead of " and % respoectively
unbind '"'
unbind %
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

# Vim Navigation
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
  | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
  | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"

bind -n C-h run "($is_vim && tmux send-keys C-h) || \
                 tmux select-pane -L"

bind -n C-j run "($is_vim && tmux send-keys C-j)  || \
                 ($is_fzf && tmux send-keys C-j) || \
                 tmux select-pane -D"

bind -n C-k run "($is_vim && tmux send-keys C-k) || \
                 ($is_fzf && tmux send-keys C-k)  || \
                 tmux select-pane -U"

bind -n C-l run "($is_vim && tmux send-keys C-l) || \
                 tmux select-pane -R"

# This tmux statusbar config was created by tmuxline.vim
# on Mon, 28 Nov 2022

set -g status-justify "left"
set -g status "on"
set -g status-left-style "none"
set -g message-command-style "fg=#eeffff,bg=#2c3b41"
set -g status-right-style "none"
set -g pane-active-border-style "fg=#89ddff"
set -g status-style "none,bg=#37474f"
set -g message-style "fg=#eeffff,bg=#2c3b41"
set -g pane-border-style "fg=#2c3b41"
set -g status-right-length "100"
set -g status-left-length "100"
setw -g window-status-activity-style "none"
setw -g window-status-separator ""
setw -g window-status-style "none,fg=#eeffff,bg=#37474f"
set -g status-left "#[fg=#1a2327,bg=#89ddff,bold] #S #[fg=#89ddff,bg=#37474f,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=#2c3b41,bg=#37474f,nobold,nounderscore,noitalics]#[fg=#eeffff,bg=#2c3b41] ☸ #(kubectl config current-context)  #T #[fg=#89ddff,bg=#2c3b41,nobold,nounderscore,noitalics]#[fg=#1a2327,bg=#89ddff] #h "
setw -g window-status-format "#[fg=#eeffff,bg=#37474f] #I #[fg=#eeffff,bg=#37474f] #W "
setw -g window-status-current-format "#[fg=#37474f,bg=#2c3b41,nobold,nounderscore,noitalics]#[fg=#eeffff,bg=#2c3b41] #I #[fg=#eeffff,bg=#2c3b41] #W #[fg=#2c3b41,bg=#37474f,nobold,nounderscore,noitalics]"