# --- General Settings ---
# Set the main prefix to C-a
set-option -g prefix C-a

# Set a secondary, "legacy" prefix to C-b for an easier transition
# With the new changes forcing me to use tmux, we're gonna try C-a
# set-option -g prefix2 C-b

# Still unbind the default C-b binding for the "send-prefix" command,
# as we want our primary prefix (C-a) to handle that.
unbind C-b
bind-key C-a send-prefix

# Clipboard lol
set -g allow-passthrough on

# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

# Enable mouse mode (scrolling, pane selection)
set -g mouse on

# --- Keybindings ---
# More intuitive split keys (current path is preserved)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# Quick pane navigation with Alt + Arrow keys
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

# --- Plugins ---
# TPM
set -g @plugin 'tmux-plugins/tpm' # TPM itself (tmux plugin manager)

# General
set -g @plugin 'tmux-plugins/tmux-sensible' # It tweaks a few default settings I wouldn't know to change otherwise.
set -g @plugin 'niqodea/tmux-matryoshka' # Makes nested tmux actually work


# Session management
set -g @plugin 'omerxx/tmux-sessionx' # Session manager
set -g @plugin 'tmux-plugins/tmux-resurrect' # Allows tmux environments to be saved and restored via prefix Ctrl+s and Ctrl+r
# I would also like to look into stuff like nvim session restoration: https://github.com/tmux-plugins/tmux-resurrect
set -g @plugin 'tmux-plugins/tmux-continuum' # Automatically saves with ^ every 15 minutes, and restores on tmux server start.
# Restore tmux environment on server start
set -g @continuum-restore 'on'
# Note: 
# > In order to be executed periodically, the plugin updates the status-right tmux variable. 
# > In case some plugin (usually themes) overwrites the status-right variable, the autosave feature stops working. 
# > To fix this issue, place the plugin last in the TPM plugins list.
# Keeping this in mind, in case I have issues.

# Appearance
set -g @plugin 'catppuccin/tmux' # Catppuccin on tmux because
set -g @catppuccin_flavour 'mocha' # The obvious best catppuccin flavor...

# Actually runs all the tmux plugin manager things
run '~/.tmux/plugins/tpm/tpm'


