# enable reload config via shortcut
unbind r
bind r source-file ~/.config/tmux/tmux.conf

# change prefix
unbind C-b
set -g prefix C-Space
bind-key C-Space send-prefix

# change split windows keybindings
unbind %
bind '\' split-window -h -c '#{pane_current_path}'
unbind '"'
bind - split-window -v -c '#{pane_current_path}'

# resize windows like vim
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
bind -r h resize-pane -L 5

# maximixe and minimize pane
bind m resize-pane -Z

# enable the mouse
set -g mouse on

# set up vim movement for tmux
set-window-option -g mode-keys vi

# send special sequences to app that support them (ex: ctrl+; to vim)
set -g extended-keys on

# problem with gnome terminal that doesn't support coping via xterm (ensure xclip is installed)
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -selection clipboard -i"
###########################################
bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
#bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"
unbind -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode after dragging with mouse

# configure tmux plugin manager (tpm)
# tpm can install plugin via prefix+i
# tpm plugin
set -g @plugin 'tmux-plugins/tpm'

# list of tmux plugins
set -g @plugin 'christoomey/vim-tmux-navigator' # for navigating panes and vim/nvim with Ctrl-hjkl
#set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
#set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes

#set -g @resurrect-capture-pane-contents 'on' # allow tmux-ressurect to capture pane contents
# set -g @continuum-restore 'on' # enable tmux-continuum functionality

# status bar color
set -g status-style "bg=default, fg=white"

# customize status bar
set -g status-right "#{?client_prefix,^*^,} %d/%m %H:%M"
set -g message-style fg=yellow,blink; set-option -ag message-style bg=default
set -g status-left-length 30 # character count

# customize windows/sessions selector
set -wg mode-style "bg=white,fg=black"

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