# ==== Common ====
# rebind PREFIX to C-a
set-option -g prefix C-a

# set title for terminal(using tmux sesion/window name)
set-option -g set-titles on
set-option -g set-titles-string "#S / #W"

# send interval to 1s to avoid conflicts with vim
set -sg escape-time 1
# set session starts with 1
set -g base-index 1
# set pane starts with 1 
setw -g pane-base-index 1
# enable mouse
set -g mouse on
# set history limit
set -g history-limit 10000
# reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# send C-a to other apps
bind C-a send-prefix
# split window horizontally
bind | split-window -h -c "#{pane_current_path}"
# split window vertically
bind - split-window -v -c "#{pane_current_path}"
# create new window with current path
bind c new-window -c "#{pane_current_path}"
# reorder windows
bind R                                      \
    move-window -r\;                        \
    display-message "Windows reordered..."

# move cursor between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# rename session/window
bind n command-prompt 'rename-window %%'
bind N command-prompt 'rename-session %%'

# switch window
bind-key ,      previous-window # <
bind-key .      next-window     # >
bind-key <      swap-window -t :-
bind-key >      swap-window -t :+
# move cursor between windows 
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# ajdust pane size
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '30'

# Colors
set -g default-terminal "screen-256color"
set -g terminal-overrides ',xterm-256color:Tc'

# Dracula Color
white='#f8f8f2'        # Foreground
dark_gray='#282a36'    # Background
gray='#44475a'         # Current Line / Selection
light_purple='#bd93f9' # Purple
dark_purple='#6272a4'  # Comment
cyan='#8be9fd'         # Cyan
green='#50fa7b'        # Green
orange='#ffb86c'       # Orange
red='#ff5555'          # Red
pink='#ff79c6'         # Pink
yellow='#f1fa8c'       # Yellow

set -g status on
set -g status-fg $dark_purple
set -g status-bg $gray
set -g status-justify left
set -g status-interval 1

set -g status-left-length 100
set -g status-right-length 100

# Options -> ⧉ ❐
set -g status-left "#{?client_prefix,#[fg=$dark_gray bg=$green],#[fg=$dark_gray bg=$light_purple]} ⧉ #S "
set -g status-right "#[fg=$white] #{pane_current_path}"

set-window-option -g window-status-current-style "fg=$dark_purple bg=$white"
set-window-option -g window-status-current-format "#[bold italics] #I: #W #F "

# for some unknown reason this tmux section is being set to reverse from
# somewhere so we explictly remove it here
set-window-option -g window-status-style "fg=$dark_gray dim"
set-window-option -g window-status-format "#[none] #I: #{=20:window_name} "
set-window-option -g window-status-separator ""

# Set window notifications
set-option -g monitor-activity on
set-option -g visual-activity off

