#------------------------------------------------------------------------------#
# vim:set ft=sh                                     ("set modeline" in ~/.exrc)#
#------------------------------------------------------------------------------#
# Config file  : ~/.tmux.conf                                                  #
#                                                                              #
# Author       : Adam Veldhousen                               The USA         #
#------------------------------------------------------------------------------#

#default to zsh
set -g default-command /bin/zsh
set -g default-shell /bin/zsh

# enable pbcopy and pbpaste support with reattach-to-user-namespace
set-option -g default-command "reattach-to-user-namespace -l zsh"
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
bind C-v run "tmux set-buffer \"$(reattach-to-user-namespace pbpaste)\"; tmux paste-buffer"

set -g default-terminal screen-256color

# set esc-wait off, so vim works
set-option -sg escape-time 0

#set prefix to alt-a
set-option -g prefix C-a
bind-key C-a send-prefix

# some nice ops
set-option -g bell-action any
set-option -g history-limit 10000
set-option -g set-titles on
set-option -g set-titles-string ' #I-#W '
set-option -g repeat-time 500
set-option -g visual-bell on

#status bar
set-option -g status-utf8 on
set-option -g status-keys vi
set-option -g status-interval 5
set-option -g status-justify left
set-option -g status-left ' #h | Adam Veldhousen'
set-option -g status-right 'tmux is rad | %d-%m-%Y %H:%M:%ss #[default]'

# copy mode
set-option buffer-limit 10

#window options
set-window-option -g utf8 on
set-window-option -g clock-mode-style 24
set-window-option -g monitor-activity on
set-window-option -g automatic-rename on
set-window-option -g mode-mouse on

# Window nav
unbind-key 1          ; bind-key 1          select-window -t 1
unbind-key 2          ; bind-key 2          select-window -t 2
unbind-key 3          ; bind-key 3          select-window -t 3
unbind-key 4          ; bind-key 4          select-window -t 4
unbind-key 5          ; bind-key 5          select-window -t 5
unbind-key 6          ; bind-key 6          select-window -t 6
unbind-key 7          ; bind-key 7          select-window -t 7
unbind-key 8          ; bind-key 8          select-window -t 8
unbind-key 9          ; bind-key 9          select-window -t 9
unbind-key 0          ; bind-key 0          select-window -t 0
#maybe bind alt key + num

#pane selection
unbind-key left            ; bind-key left        select-pane -L
unbind-key right           ; bind-key right       select-pane -R
unbind-key up              ; bind-key up          select-pane -U
unbind-key down            ; bind-key down        select-pane -D
#vim binding
unbind-key h               ; bind-key h           select-pane -L
unbind-key l               ; bind-key l           select-pane -R
unbind-key k               ; bind-key k           select-pane -U
unbind-key j               ; bind-key j           select-pane -D

#pane resizing
unbind-key J            ; bind-key -r J           resize-pane -D 5
unbind-key K            ; bind-key -r K           resize-pane -U 5
unbind-key L            ; bind-key -r L           resize-pane -R 5
unbind-key H            ; bind-key -r H           resize-pane -L 5

# window splitting
unbind-key M-i            ; bind-key M-i          split-window -v
unbind-key M-s            ; bind-key M-s          split-window -h
unbind-key i              ; bind-key i            split-window -v
unbind-key s              ; bind-key s            split-window -h

#nice bindings 
unbind-key R               ; bind-key R           source-file ~/.tmux.conf
unbind-key q               ; bind-key q           list-keys
unbind-key M-q             ; bind-key M-q         list-keys

# vim behavior
setw -g mode-keys vi
unbind [                   ; bind Escape copy-mode
unbind p                   ; bind p paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection

#vim airline integration
source ~/Tools/vim/.vimrc

#unbind-key ^A-c          ; bind-key -n ^A-c         copy-mode
#unbind-key ^A-NPage      ; bind-key -n ^A-NPage     copy-mode
#unbind-key ^A-PPage      ; bind-key -n ^A-PPage     copy-mode
#unbind-key ^A-i          ; bind-key -n ^A-i         paste-buffer
#unbind-key ^A-P          ; bind-key -n ^A-P         paste-buffer
