# set correct term
set -g default-terminal screen-256color

# set prefix key to ctrl+t
unbind C-b
set -g prefix C-a

# suspend-client?  Derp.
unbind C-z

# reload config without killing server
bind R source-file ~/.rcs/tmux/global \; display-message "  Config reloaded..."

# more intuitive keybindings for splitting
unbind %
#bind-key -n C-h split-window -v
bind 'h' split-window -v
unbind '"'
#bind-key -n C-v split-window -h
bind 'v' split-window -h

# copy tmux buffer to clipboard
#bind C-y run "tmux show-buffer | xsel -b"
# move x clipboard into tmux paste buffer
#bind C-p run "tmux set-buffer \"$(xsel -o)\"; tmux paste-buffer"

# pane selection
#bind-key -n C-j select-pane -t :.+
#bind-key -n C-k select-pane -t :.-

# quick view of processes
bind 't' split-window "exec top"

# open {tmux,mutt,vim} man page
#bind-key T neww -n "Tmux manual" "exec man tmux"

# open %% man page
bind C-m command-prompt -p "Open man page for:" "new-window 'exec man %%'"

# send the prefix to client inside window (ala nested sessions)
bind-key C-a send-prefix

# toggle last window like screen
#bind-key C-b last-window

# confirm before killing a window or the server
bind-key k kill-window
bind-key \\ kill-session
#bind-key \ kill-server # all tmux sessions

bind-key X break-pane
bind-key x kill-pane

# toggle statusbar
bind-key b set-option status

# ctrl+left/right cycles thru windows
bind-key -n C-n next
bind-key -n C-p prev
bind-key -n C-right next
bind-key -n C-left prev

# scrollback buffer n lines
set -g history-limit 5000

# listen for activity on all windows
set -g bell-action any

# on-screen time for display-panes in ms
set -g display-panes-time 2000

# enable wm window titles
set -g set-titles on

# enable auto renaming
setw -g automatic-rename on

# border colour
set -g pane-border-style fg=white,bg=default
set -g pane-active-border-style fg=white,bg=default

# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux:#I [ #T ]"

# environment
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"

# vi key bindings (for copy mode and stuff)
set-window-option -g mode-keys vi
#bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-selection

# statusbar --------------------------------------------------------------
set -g window-status-format "#I:#W"
set -g window-status-current-format "#I:#W"

set -g status-interval 1
set -g status-justify left # left align window list

# default statusbar colors
set -g status-fg white
set -g status-bg default

# default window title colors
set-window-option -g window-status-style fg=white,bg=default,dim

# active window title colors
set-window-option -g window-status-current-style fg=white,bg=default,underscore,dim,reverse

# command/message line colors
set -g message-style fg=white,bg=black,bright

#set -g status-right '#(~/.network_activity)#(cat /proc/loadavg | cut -d" " -f1-3) | %H:%M %b %d'
set -g status-right '#(cat /proc/loadavg | cut -d" " -f1-3)'

