#          ╭──────────────────────────────────────────────────────────╮
#          │                       Keybindings                        │
#          ╰──────────────────────────────────────────────────────────╯
#   ──────────────────────────────── prefix ────────────────────────────────
unbind C-b
set -g prefix C-Space

#   ────────────────── prefix ctrl+a for nested sessions ────────────────
bind-key -n C-a send-prefix

#   ────────────────── default split shortcuts overwrite ────────────────
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

#   ─────────────────────────── selecting panes ─────────────────────────
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

#   ────────────────────────────── move panes ──────────────────────────────
# bind j command-prompt -p "join pane from:"  "join-pane -s '%%'"
# bind s command-prompt -p "send pane to:"  "join-pane -t '%%'"

#   ───────────────── Shift Alt vim keys to switch windows ─────────────────
bind -n M-H previous-window
bind -n M-L next-window
bind -n M-K switch-client -p
bind -n M-J switch-client -n

#   ─────────────────── trying to make home end working ─────────────────
bind-key -n Home send Escape "OH"
bind-key -n End send Escape "OF"
# unbind shift+<-/-> to switch tabs
unbind S-Left
unbind S-Right

#          ╭──────────────────────────────────────────────────────────╮
#          │                     general settings                     │
#          ╰──────────────────────────────────────────────────────────╯
#   ──────────────────────────── default shell ──────────────────────────
set-option -g default-shell /bin/zsh

#   ───────────────────────────── enable mouse ─────────────────────────────
set -g mouse on

#   ──────────────────────────── enable vi mode ────────────────────────────
set-window-option -g mode-keys vi

#   ────────────────── enable autorename to current path ────────────────
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'

#   ──────────────────────── some terminal options ──────────────────────
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'  # underscore colours - needs tmux-3.0

#   ─────────────────────────────── copying ─────────────────────────────
set -g set-clipboard on
set -g @override_copy_command 'xclip -i -selection clipboard'
set -g @yank_selection 'clipboard'
set -as terminal-features ',*:clipboard'

#   ───────────────── Start windows and panes at 1, not 0 ───────────────
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on

#   ───────────────────────── enabling passthrough ─────────────────────────
set -g allow-passthrough on
set -g visual-activity off

#          ╭──────────────────────────────────────────────────────────╮
#          │                         Plugins                          │
#          ╰──────────────────────────────────────────────────────────╯

#   ───────────────────────── tmux plugin manager ───────────────────────
set -g @plugin 'tmux-plugins/tpm'

#   ── some default options https://github.com/tmux-plugins/tmux-sensible ──
set -g @plugin 'tmux-plugins/tmux-sensible'

#   ─────────────────────────── better tmux yank ───────────────────────────
set -g @plugin 'tmux-plugins/tmux-yank'

#   ───────── some cool search shortcuts like <prefix>+ctrl+u etc ───────
set -g @plugin 'tmux-plugins/tmux-copycat'

#   ───────────── shortcut for xdg-open file/url under cursor ───────────
set -g @plugin 'tmux-plugins/tmux-open'

#   ────────────────────────── vim tmux navigator ──────────────────────────
set -g @plugin 'christoomey/vim-tmux-navigator'

#   ─────────────────────── tmux sessions managment ─────────────────────
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-capture-pane-contents 'on' # save pane contents
set -g @resurrect-strategy-nvim 'session' # resurrect nvim sessions

#   ───────────────── automatically save/restore sessions ───────────────
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on' # enabling

#          ╭──────────────────────────────────────────────────────────╮
#          │                      gruvbox theme                       │
#          ╰──────────────────────────────────────────────────────────╯
set -g @plugin 'egel/tmux-gruvbox'
set -g @tmux-gruvbox 'dark'

#          ╭──────────────────────────────────────────────────────────╮
#          │                      Dracula theme                       │
#          ╰──────────────────────────────────────────────────────────╯
# 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 @plugin 'dracula/tmux'
# set -g @dracula-show-powerline true
# set -g @dracula-plugins "git network network-vpn platerctl time battery"
# # it can accept `hostname` (full hostname), `session`, `shortname` (short name), `smiley`, `window`, or any character.
# set -g @dracula-show-left-icon session
# set -g @dracula-show-empty-plugins false
# set -g @dracula-battery-label "🔋"
# set -g @dracula-show-timezone false
# set -g @dracula-military-time true
# set -g @dracula-day-month true
# set -g @dracula-show-fahrenheit false
# set -g @dracula-playerctl-format "►  {{ artist }} - {{ title }}"
# # for left
# set -g @dracula-show-left-sep \uE0C0
#
# # for right symbol (can set any symbol you like as separator)
# set -g @dracula-show-right-sep \uE0B2

#          ╭──────────────────────────────────────────────────────────╮
#          │                 run tmux plugin manager                  │
#          ╰──────────────────────────────────────────────────────────╯
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'