# Defaults, rest will be set with tmux-sensible
set -g default-terminal "tmux"
set -g default-shell $SHELL
set -g prefix C-a
set -g base-index 1
setw -g pane-base-index 1
setw -g xterm-keys on
setw -g mode-keys vi
set-option -as terminal-overrides ",xterm*:RGB"

# Copy & Paste with clipper -- see https://github.com/wincent/clipper
# starting copy & paste with Ctrl+a [
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel "nc localhost 8377"
bind-key -T copy-mode-vi Escape send -X cancel

# Saner window splitting / new windows
bind-key '\' split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
bind-key c new-window -c "#{pane_current_path}"

# Mouse support
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M

# Custom statusbar
set -g status-style bg=black,fg=yellow,default
set -g pane-border-style fg=black
set -g pane-active-border-style fg=brightgreen
set -g message-style bg=black,fg=brightred
set -g display-panes-active-colour blue
set -g display-panes-colour brightred
set -g status-left-length 32
set -g status-right-length 150
set -g status-left-length 60
set -g status-left '#[fg=black,bg=white] ❐ #S #[fg=white,bg=default,nobold] ⣿ #P '
set -g status-right '#[fg=white,bg=default,nobold] #(whoami)@#h# #[fg=black,bg=white,nobold] #(date +"%H:%M") '
set -g window-status-format '#[fg=white,bg=default] #I #W '
set -g window-status-current-format '#[fg=black,bg=blue] #I #W #[fg=blue,bg=black,nobold]'
setw -g window-status-style fg=white,bg=default
setw -g window-status-current-style fg=brightred,bg=default
setw -g clock-mode-colour green

# Plugin configuration
set -g @resurrect-processes 'l nnn v vim nvim m mutt neomutt'
set -g @continuum-restore 'on'
set -g @continuum-boot 'off'

# Plugins loading and tmux plugin manager initialization
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'schasse/tmux-jump'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tpm'
run '~/.tmux/plugins/tpm/tpm'
