set -g mouse on
set -g default-terminal "screen-256color"
set -g detach-on-destroy off     # don't exit from tmux when closing a session
set -g escape-time 0             # zero-out escape time delay
set -g history-limit 50000
set -g renumber-windows on       # renumber all windows when any window is closed
set -g set-clipboard on          # use system clipboard
set -g base-index 1
set -g pane-base-index 1
set -gq allow-passthrough on
set -g visual-activity off

#Remove *all* keybindings
unbind-key -a
set -g status-keys vi
set -g mode-keys vi

set -g prefix C-Space

#General
bind ^D detach
bind r command-prompt "rename-session '%%'"
bind R source-file ~/.config/tmux/tmux.conf
bind : command-prompt
bind ^L send-keys "clear"\; send-keys "Enter"

#Windows
bind c new-window
bind w choose-window
bind C kill-window
bind p previous-window
bind n next-window
bind f last-window
bind-key -n M-1 selectw -t 1
bind-key -n M-2 selectw -t 2
bind-key -n M-3 selectw -t 3
bind-key -n M-4 selectw -t 4
bind-key -n M-5 selectw -t 5
bind-key -n M-6 selectw -t 6
bind-key -n M-7 selectw -t 7
bind-key -n M-8 selectw -t 8
bind-key -n M-9 selectw -t 9
bind-key -n M-0 selectw -t 10
#Panes
bind e split-window -v -c "#{pane_current_path}"
bind i split-window -h -c "#{pane_current_path}"
bind X kill-pane
bind m resize-pane -Z
bind -r -T prefix h resize-pane -L 1
bind -r -T prefix j resize-pane -D 1
bind -r -T prefix k resize-pane -U 1
bind -r -T prefix l resize-pane -R 1

#Copy mode
bind v copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line

#Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'alexwforsythe/tmux-which-key'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'catppuccin/tmux#v2.1.2'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'omerxx/tmux-sessionx'
set -g @plugin 'omerxx/tmux-floax'


#Configure plugins
set -g @resurrect-strategy-nvim 'session'
set -g @ressurect-capture-pane-contents 'on'
set -g @continuum-save-interval '5'
set -g @continuum-restored 'on'

set -g @floax-width '80%'
set -g @floax-height '80%'
set -g @floax-border-color 'magenta'
set -g @floax-text-color 'blue'
set -g @floax-bind 'p'
set -g @floax-change-path 'true'

set -g @sessionx-bind-zo-new-window 'ctrl-y'
set -g @sessionx-auto-accept 'off'
set -g @sessionx-bind 'o'
set -g @sessionx-window-height '60%'
set -g @sessionx-window-width '75%'
set -g @sessionx-zoxide-mode 'on'
set -g @sessionx-custom-paths-subdirectories 'false'
set -g @sessionx-filter-current 'false'

set -g @catppuccin_flavor 'mocha'
set -g @catppuccin_status_background "none"
set -g @catppuccin_window_status_style "none"
set -g @catppuccin_pane_status_enabled "off"
set -g @catppuccin_pane_border_status "off"
# 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"
# 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_mode_text ""
# set -g @catppuccin_directory_text " #{pane_current_path}"

# source the plugin here
run '~/.tmux/plugins/tpm/tpm'
run '#{TMUX_PLUGIN_MANAGER_PATH}/tmux/catppuccin.tmux'

# set -Fg 'status-format[1]' '#{status-format[0]}'
# set -g 'status-format[0]' ''
# set -g status 2

set -g @ctp_bg "#24273a"
set -g @ctp_mocha "#1e1e2e"
set -g @ctp_surface_1 "#494d64"
set -g @ctp_fg "#cad3f5"
set -g @ctp_mauve "#c6a0f6"
set -g @ctp_crust "#181926"
set -g @ctp_blue "#89b4fa"       # Blue
set -g @ctp_cyan "#94e2d5"       # Cyan
set -g @ctp_green "#a6e3a1"      # Green
set -g @ctp_red "#f38ba8"        # Red
set -g @ctp_yellow "#f9e2af"     # Yellow
set -g @ctp_pink "#f5c2e7"


set -g status-position bottom
set -g status-interval 1
set -g status-style "bg=#{@ctp_mocha}"
set -g status-justify "absolute-centre"

set -g status-left-length 100
set -g status-left ""
set -ga status-left "#[bg=#{@thm_bg},fg=#{@ctp_mauve}]  #{pane_current_command} "
set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_overlay_0},none]│"
set -ga status-left "#[bg=#{@thm_bg},fg=#{@ctp_blue}]  #{=/-32/...:#{s|$USER|~|:#{b:pane_current_path}}} "
set -ga status-left "#[bg=#{@thm_bg},fg=#{@ctp_pink},none]#{?window_zoomed_flag,│,}"
set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_yellow}]#{?window_zoomed_flag,  zoom ,}"


set -g status-right-length 100
set -g status-right " #{?client_prefix,#[fg=#{@thm_red} bold]PREFIX ,#{?#{==:#{pane_mode},copy-mode},#[fg=#{@thm_yellow} bold]COPY ,#[fg=#{@thm_green} bold]NORMAL }}"
set -ga status-right "#[bg=#{@thm_bg},fg=#{@thm_overlay_0},none]│"
set -ga status-right "#{?client_prefix,#{#[bg=#{@thm_red},fg=#{@thm_bg},bold]  #S },#{?#{==:#{pane_mode},copy-mode},#{#[bg=#{@thm_yellow},fg=#{@thm_bg},bold]  #S },#{#[bg=#{@thm_bg},fg=#{@thm_green},bold]  #S }}}"

setw -g pane-border-status bottom
setw -g pane-border-status bottom
setw -g pane-border-format " Arch "
setw -g pane-active-border-style "bg=#{@thm_bg},fg=#{@thm_overlay_0}"
setw -g pane-border-style "bg=#{@thm_bg},fg=#{@thm_surface_0}"
setw -g pane-border-lines double

set -g window-status-format " #I#{?#{!=},: #W,} "
set -g window-status-style "bg=#{@thm_bg},fg=#{@thm_rosewater}"
set -g window-status-last-style "bg=#{@thm_bg},fg=#{@thm_peach}"
set -g window-status-activity-style "bg=#{@thm_red},fg=#{@thm_bg}"
set -g window-status-bell-style "bg=#{@thm_red},fg=#{@thm_bg},bold"
set -gF window-status-separator "#[bg=#{@thm_bg},fg=#{@thm_overlay_0}]│"

set -g window-status-current-format " #I#{?#{!=},: #W,} "
set -g window-status-current-style "bg=#{@ctp_mauve},fg=#{@thm_bg},bold"
