# Some tweaks to the status line
set -g status-right '#{prefix_highlight} | %a %Y-%m-%d %H:%M'
# set -g window-status-current-style "underscore"

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

# 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"

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

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

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

# Turn the mouse on, but without copy mode dragging
set -g mouse on
# unbind -n MouseDrag1Pane
# unbind -Tcopy-mode MouseDrag1Pane
bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-no-clear
set -s set-clipboard external

# Some extra key bindings to select higher numbered windows
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
bind F4 selectw -t:13
bind F5 selectw -t:14
bind F6 selectw -t:15
bind F7 selectw -t:16
bind F8 selectw -t:17
bind F9 selectw -t:18
bind F10 selectw -t:19
bind F11 selectw -t:20
bind F12 selectw -t:21

# 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}'

unbind C-Space
set -g prefix C-Space
bind C-Space send-prefix

set -g mouse on
set-option -g history-limit 5000
bind \` switch-client -t'{marked}'
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on

# rebind horizontal and vertical split to Prefix (C-Space) + | and - respectively
bind | split-window -hc "#{pane_current_path}"
bind - split-window -vc "#{pane_current_path}"

# spaw left and right windows
bind -r "<" swap-window -d -t -1
bind -r ">" swap-window -d -t +1

bind Space last-window

# resize with Prefix + C-h/j/k/l
bind -r C-j resize-pane -D 15
bind -r C-k resize-pane -U 15
bind -r C-h resize-pane -L 15
bind -r C-l resize-pane -R 15

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind r source-file ~/.tmux.conf \; display "Reloaded tmux config"

set-window-option -g mode-keys vi
set -g mode-keys vi
set -g status-keys vi

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'alexwforsythe/tmux-which-key'
# set -g @plugin 'tmux-plugins/tmux-prefix-highlight'

# # dracula config
# set -g @plugin 'dracula/tmux'
# set -g @dracula-plugins "time"
# set -g @dracula-show-powerline true
# set -g @dracula-show-flags true
# set -g @dracula-show-left-icon session
# set -g @dracula-show-timezone false
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, ssh-session, attached-clients, network-vpn, weather, time, mpc, spotify-tui, playerctl, kubernetes-context, synchronize-panes
# set -g @dracula-plugins "git ssh-session"

# set -g @plugin 'catppuccin/tmux#v2.1.3' # See https://github.com/catppuccin/tmux/tags for additional tags
# Make the status line pretty and add some modules
set -g status-right-length 100
set -g status-left-length 100
set -g status-left ""
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_uptime}"
set -g @catppuccin_flavor 'macchiato' # latte, frappe, macchiato or mocha

# Menu styling options
set -gq @catppuccin_menu_selected_style "fg=#{@thm_fg},bold,bg=#{@thm_overlay_0}"

# Pane styling options
set -gq @catppuccin_pane_status_enabled "yes" # set to "yes" to enable
set -gq @catppuccin_pane_border_status "off" # set to "yes" to enable
set -gq @catppuccin_pane_border_style "fg=#{@thm_overlay_0}"
set -gq @catppuccin_pane_active_border_style "##{?pane_in_mode,fg=#{@thm_lavender},##{?pane_synchronized,fg=#{@thm_mauve},fg=#{@thm_lavender}}}"
set -gq @catppuccin_pane_left_separator "█"
set -gq @catppuccin_pane_middle_separator "█"
set -gq @catppuccin_pane_right_separator "█"
set -gq @catppuccin_pane_color "#{@thm_green}"
set -gq @catppuccin_pane_background_color "#{@thm_surface_0}"
set -gq @catppuccin_pane_default_text "##{b:pane_current_path}"
set -gq @catppuccin_pane_default_fill "number"
set -gq @catppuccin_pane_number_position "left" # right, left

set -gq @catppuccin_window_text_color "#{@thm_surface_0}"
set -gq @catppuccin_window_number_color "#{@thm_overlay_2}"
set -q @catppuccin_window_text " #W"
set -q @catppuccin_window_current_text " #W"
set -gq @catppuccin_window_number "#I"
set -gq @catppuccin_window_current_text_color "#{@thm_surface_1}"
set -gq @catppuccin_window_current_number_color "#{@thm_mauve}"
set -gq @catppuccin_window_current_text " #T"
set -gq @catppuccin_window_current_number "#I"
set -gq @catppuccin_window_number_position "left"
set -gq @catppuccin_window_flags "icon" # none, icon, or text
set -gq @catppuccin_window_flags_icon_last " 󰖰" # -
set -gq @catppuccin_window_flags_icon_current " 󰖯" # *
set -gq @catppuccin_window_flags_icon_zoom " 󰁌" # Z
set -gq @catppuccin_window_flags_icon_mark " 󰃀" # M
set -gq @catppuccin_window_flags_icon_silent " 󰂛" # ~
set -gq @catppuccin_window_flags_icon_activity " 󱅫" # #
set -gq @catppuccin_window_flags_icon_bell " 󰂞" # !
# Matches icon order when using `#F` (`#!~[*-]MZ`)
set -gq @catppuccin_window_flags_icon_format "##{?window_activity_flag,#{E:@catppuccin_window_flags_icon_activity},}##{?window_bell_flag,#{E:@catppuccin_window_flags_icon_bell},}##{?window_silence_flag,#{E:@catppuccin_window_flags_icon_silent},}##{?window_active,#{E:@catppuccin_window_flags_icon_current},}##{?window_last_flag,#{E:@catppuccin_window_flags_icon_last},}##{?window_marked_flag,#{E:@catppuccin_window_flags_icon_mark},}##{?window_zoomed_flag,#{E:@catppuccin_window_flags_icon_zoom},} "

# allow nvim images
set -gq allow-passthrough on
set -g visual-activity off

set -g @catppuccin_window_status_style "rounded" # basic, rounded, slanted, custom, or none

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