# set the prefix to ^G

set  -g default-terminal screen-256color
set  -g history-limit 100000
set  -g mouse-select-pane on
set  -g mouse-resize-pane on
set -wg mode-mouse on
set -wg xterm-keys       1
set  -g status-keys     vi
set -wg mode-keys       vi
set  -s escape-time    100

unbind C-b
set -g prefix C-g
bind g   send-prefix
bind C-g send-prefix

bind -n F5 source ~/.tmux.conf
bind -n M-x command-prompt

bind d detach
bind -n C-\ detach
bind -n C-up    resize-pane -U
bind -n C-down  resize-pane -D
bind -n C-left  resize-pane -L
bind -n C-right resize-pane -R

bind n   next-window
bind C-n next-window
bind p   previous-window
bind C-p previous-window
bind s   command-prompt "split-window -v '%%'"
bind S   command-prompt "split-window -v '%%'"
bind v   command-prompt "split-window -h '%%'"
bind C-v command-prompt "split-window -h '%%'"

bind Enter new-window
bind r command-prompt "new-window '%%'"
bind c confirm-before kill-pane
bind x confirm-before kill-pane
bind ! command-prompt -p Man: "split-window 'man %%'"
bind o break-pane

bind h select-pane -L
bind k select-pane -U
bind j select-pane -D
bind l select-pane -R
bind K swap-pane -U
bind J swap-pane -D
bind i display-message \; display-panes
set  -g display-panes-time 1500
set  -g display-time       1500

set  -g base-index 1
bind Tab choose-window
bind 1 select-window -t 1
bind 2 select-window -t 2
bind 3 select-window -t 3
bind 4 select-window -t 4
bind 5 select-window -t 5
bind 6 select-window -t 6
bind 7 select-window -t 7
bind 8 select-window -t 8
bind 9 select-window -t 9
bind 0 select-window -t 10

##############################################################################
# Copy Mode
bind Escape copy-mode
bind C-' ' copy-mode
bind    -t vi-copy C-u    page-up
bind    -t vi-copy C-d    page-down
bind    -t vi-copy G      bottom-line
bind -n -t vi-copy Escape cancel
bind -n -t vi-copy |      start-of-line

bind - run-shell     "tmux show-buffer | xclip"
bind = choose-buffer "run-shell 'tmux show-buffer -b %% | xclip'"

##############################################################################
# Edit mode
bind -n -t vi-edit Escape switch-mode
bind -n -t vi-edit Up     history-up
bind -n -t vi-edit Down   history-down
bind -n -t vi-edit Left   cursor-left
bind -n -t vi-edit Right  cursor-right
bind -n -t vi-edit C-u    delete-line
bind -n -t vi-edit C-k    delete-end-of-line

bind -c -t vi-edit Escape cancel
bind -c -t vi-edit |      start-of-line

##############################################################################
# Bells
set  -g visual-activity  on
set  -g visual-bell      off
set  -g bell-action      any
set -wg monitor-activity off

##############################################################################
# Theme
set  -g status         on
set  -g status-attr    default
set  -g status-fg      white
set  -g status-bg      default
set  -g status-justify centre
set  -g status-utf8    on

set  -g status-left    "#[fg=green]["
set  -g status-right   "#[fg=green]]"

# command/message line colors
set -g message-fg   white
set -g message-bg   red
set -g message-attr bright

# default window title colors
set -wg window-status-fg   white
set -wg window-status-bg   default
set -wg window-status-attr dim

set -wg window-status-format         '#I #W#F'
set -wg window-status-current-format '#[fg=red,nobold][#[fg=white,bold]#I #W#F#[fg=red,nobold]]'

set -g pane-border-bg default
set -g pane-border-fg default
set -g pane-active-border-bg default
set -g pane-active-border-fg red

# active window title colors
set -wg window-status-current-fg   white
set -wg window-status-current-bg   default
set -wg window-status-current-attr bright
