################################################################################
#                              Base configuration
################################################################################
# Use Ctrl-a as a prefix instead of Ctrl-b
set -g prefix C-a
unbind C-b

# More responsive with sending commands
set -sg escape-time 1

# Start counting at 0, easier for keyboard shortcuts
set -g base-index 1
set-window-option -g pane-base-index 1

# Mouse options
set -g mouse-select-pane off
set -g mouse-resize-pane off
set -g mouse-select-window off
setw -g mode-mouse off

# Status
set -g status-interval 20
set -g status-utf8 on
set -g status-justify centre

set -g status-left "#[fg=colour75]#S:#I.#P" #colour75 is an awesome blue
set -g status-right "#[fg=colour75]%F %l:%M%P" #colour75 is an awesome blue

setw -g monitor-activity on
set -g visual-activity on

################################################################################
#                                    Colors
################################################################################
set -g default-terminal "screen-256color"

set -g status-fg white
set -g status-bg black

setw -g window-status-fg colour108 # colour108 is an olive color
setw -g window-status-bg default
setw -g window-status-attr dim

setw -g window-status-current-fg colour156 # colour156 is a lime green color
setw -g window-status-current-bg default
setw -g window-status-current-attr bright

set -g pane-border-fg colour108
set -g pane-border-bg default
set -g pane-active-border-fg colour156
set -g pane-active-border-bg default

set -g message-fg white
set -g message-bg black
set -g message-attr bright

################################################################################
#                               Custom bindings
################################################################################
# Have buffers be more like vim buffers
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

# integrate with system clipboard
bind C-c run 'tmux save-buffer - | xclip -i -sel clipboard'
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# Make current pane into it's own temp window
unbind Up
bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
unbind Down
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp

# Make switch session shortcut repeatable
bind -r ( switch-client -p
bind -r ) switch-client -n

bind P pipe-pane -o "cat >> ~/#S-#W.log" \; display "Toggled logging to ~/#S-#W.log"

# Reload config with prefix r
bind r source-file ~/.tmux.conf \; display "Reloaded"

# Send prefix to the terminal
bind C-a send-prefix

# Create panes bindings
bind | split-window -h
bind \ split-window -h
bind - split-window -v

# Vim bindings
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

