######################
# Tmux config        #
# Inspired by:       #
#   - josean.dev     #
#   - DevOps Toolbox #
######################

# Use RGB Colors
set -g default-terminal "screen-256color"

set -g base-index 1 # Start counting from 1
set -g status-position top # Position status bar at top

set -g renumber-windows on # Whenever a window is closed, renumber them

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

######################
# Change keybindings #
######################

# Vertical window split
unbind %
bind - split-window -v

# Horizontal window split
unbind '"'
bind _ split-window -h

# Window resizing
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r h resize-pane -L 5
bind -r l resize-pane -R 5
bind -r m resize-pane -Z

# Vim keys 
set-window-option -g mode-keys vi

############
# Vim Mode #
############

bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection

unbind -T copy-mode-vi MouseDragEnd1Pane

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

###########
# Plugins #
###########

set -g @plugin 'tmux-plugins/tpm' # Plugin Manager
set -g @plugin 'christoomey/vim-tmux-navigator' # vim-like navigation 
set -g @plugin 'catppuccin/tmux' # Theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

#############################################################
# Catppuccin config                                         #
# See https://github.com/catppuccin/tmux for more resources #
#############################################################

set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_text "#{window_name}"
set -g @catppuccin_window_current_text "#{window_name}"
set -g @catppuccin_window_current_fill "number"
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_flavor 'macchiato'
set -g status-right-length 100
set -g status-left-length 100
set -g status-left "#{E:@catppuccin_status_session}"
set -g status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"

####################
# Resurrect config #
####################

set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'


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