# KEY BINDINGS
# Alex Auvolat + Adrien Luxey additions

###########################
### Packages management ###
###########################

# Tmux Package Manager
# Prefix + I => Install plugins (after adding them to tmux.conf)
# Prefix + + Alt-u => uninstall
# Prefix + U => Update packages
set -g @plugin 'tmux-plugins/tpm'

# Tmux OneDark: http://github.com/odedlaz/tmux-onedark-themetheme
#set -g @plugin 'odedlaz/tmux-onedark-theme'
# Tmux-Themepack (feat Powerline)
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/default/blue'

# Save and restore Tmux sessions
# Prefix + Ctrl-s => Save current session
# Prefix + Ctrl-r => Restore
set -g @plugin 'tmux-plugins/tmux-resurrect'

# Continuous saving tmux environment (depends on Ressurect)
# Also auto-starts tmux on boot and auto-restores last session
set -g @plugin 'tmux-plugins/tmux-continuum'
#set -g status-right 'Continuum status: #{continuum_status}'
set -g @continuum-restore 'on' # Auto restore previous session
set -g @continuum-save-interval '15' # save time in minutes

# Copy to system clipboard
# Normal mode: 
# 	Prefix + y => (yank) Copies text from command line to clipboard
# Copy mode:
# 	y => copy selection to clipboard
# 	Y => Put (copy a selection then paste it to cmd)
set -g @plugin 'tmux-plugins/tmux-yank'

# There seems to be cool things to make Vim and Tmux play well together too

#####################
### Alex's stuff  ###
#####################

setw -g mode-keys vi

# remap prefix to Control + a
set -g prefix C-q
unbind C-b
bind C-q send-prefix

unbind q
bind-key q copy-mode

unbind p
bind p paste-buffer

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

# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+

# switch panes using vim-like bindings C-a hjkl
unbind h
unbind j
unbind k
unbind l
bind h select-pane -L
bind l select-pane -R
bind k select-pane -U
bind j select-pane -D
# switch windows using bindings C-q C-hl
unbind ^H
unbind ^L
bind ^H previous-window
bind ^L next-window

# OTHER OPTIONS

set -g mouse on

set -g escape-time 0

# don't rename windows automatically
set-option -g allow-rename off


######################
### DESIGN CHANGES ###
######################

# set -g status-bg colour6


##########################
### Adrien's additions ###
##########################

set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"

# Remember my path when splitting windows
bind % split-window -h -c '#{pane_current_path}'  # Split panes horizontally
bind '"' split-window -v -c '#{pane_current_path}'  # Split panes vertically

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