# Set prefix key to C-x
unbind C-b
set -g prefix C-x
bind C-x send-prefix

## set the default TERM
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",screen-256color:Tc"

## set terminal bell
set -g bell-action any

### update the TERM variable of terminal emulator when creating a new session or attaching a existing session
set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM'

# i3 split bindings
bind g split-window -h
bind v split-window -v
unbind '"'
unbind %
unbind m

# vim split navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# equalize splits with x
unbind space
bind x select-layout even-horizontal

# window switching
unbind n
unbind c
bind c new-window
unbind ,
unbind .
bind , previous-window
bind . next-window
bind-key n command-prompt "rename-window '%%'"

# change kill window bind
unbind &
bind k killp

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

#set -g default-shell /usr/local/bin/fish
#set -g default-command '/usr/local/bin/fish'
set -g status on
set -g pane-base-index 1
set -g base-index 1
set -g set-titles on
set -g aggressive-resize on
set-option -g set-titles-string '#{pane_current_command}'
set-option -g history-limit 30000
set-option -g visual-activity on
set-option -g status-position bottom
set-option -g renumber-windows on
set-window-option -g monitor-activity off
set-option -g allow-rename off

# copy mode
unbind [
bind Escape copy-mode
bind-key -T copy-mode-vi 'v' send -X begin-selection # Begin selection in copy mode.
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle # Begin selection in copy mode.
bind-key -T copy-mode-vi 'y' send -X copy-selection # Yank selection in copy mode.


set -g mouse on
bind -T root WheelUpPane   if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"  

# Split
set-option -g pane-active-border-fg colour234
set-option -g pane-active-border-bg default
set-option -g pane-border-fg colour234
set-option -g pane-border-bg default

set -g status-left '#[fg=white,bg=magenta] #S #[fg=default,bg=default]'
set -g status-right '#{prefix_highlight} #[fg=white,bg=magenta] %b %d %Y #[fg=white,bg=blue] %R '
set -g status-right-length 100
set -g status-bg default
setw -g window-status-format '#[fg=cyan,bg=black] #I #[fg=cyan,bg=black] #W '
setw -g window-status-current-format '#[fg=white,bg=blue] #I #[fg=white,bg=magenta] #W '

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Plugin configuration
set -g @resurrect-processes ':all:'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '15'
set -g @resurrect-strategy-vim 'session'

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