# Some tweaks to the status line
set -g status-right "%H:%M"
set -g window-status-current-style "underscore"
set -g status-position "top"

# If running inside tmux ($TMUX is set), then change the status line to red
%if #{TMUX}
set -g status-bg red
%endif

TMUX_FZF_OPTIONS="-p -w 60% -h 80% -m"

# Enable RGB colour if running in xterm(1)
set-option -sa terminal-overrides ",xterm*:Tc"

# Change the default $TERM to tmux-256color
set -g default-terminal "xterm-256color"

# Change windows to start with an index of 1 instead of 0
set -g base-index 1

# Change panes to start with an index of 1 instead of 0
setw -g pane-base-index 1

# No bells at all
set -g bell-action none

# Keep windows around after they exit
set -g remain-on-exit on

# Set indexes to start at 1, instead of 0.
set -g base-index 1

# Change the prefix key to C-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

# Turn the mouse on, but without copy mode dragging
set -g mouse on
unbind -n MouseDrag1Pane
unbind -Tcopy-mode MouseDrag1Pane

# A key to toggle between smallest and largest sizes if a window is visible in
# multiple places
bind F set -w window-size

# Keys to toggle monitoring activity in a window and the synchronize-panes option
bind m set monitor-activity
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'

# Better split pane
bind \\ splitw -h
bind - splitw -v

# Use Alt-arrow keys to navigate 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
bind-key -r K kill-pane

# Use Shift-arrow keys to navigate windows.
bind -n S-Left previous-window
bind -n S-Right next-window
bind -n M-h previous-window
bind -n M-L next-window
bind C-l send-keys 'C-l'

bind f run-shell "tmux display-popup -E -w 80% -h 80% ~/.local/scripts/tmux-sessionator"
bind-key -r C run-shell -b "~/.local/scripts/tmux-sessionator ~/.dotfiles"
bind S run-shell -b "~/.config/tmux/plugins/tmux-fzf/scripts/session.sh switch"

# reload new changes
bind-key r source-file ~/.config/tmux/tmux.conf\; \display-message "source-file done"

######################################## Plugins ########################################
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'tmux-plugins/tmux-yank'
#set -g @plugin 'erikw/tmux-powerline'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'catppuccin/tmux'

set -g @catppuccin_flavour 'mocha' # latte, frappe, macchiato, mocha
set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator " "
set -g @catppuccin_window_middle_separator " █"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_current_text "#W"
set -g @catppuccin_status_modules_right "directory session"
set -g @catppuccin_status_left_separator  " "
set -g @catppuccin_status_right_separator ""
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_status_connect_separator "no"

set -g @catppuccin_directory_text "#{pane_current_path}"

# Needs to stay at the bottom.
run '~/.config/tmux/plugins/tpm/tpm'
