# tmux conf
# original by gutterslob
# stolen from dkeg

# change prefix to Ctrl-a (like in gnu-screen)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# reload config fil
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# shell
set -g default-command /bin/bash
set -g default-shell /bin/bash

# start with window 1 (instead of 0)
set -g base-index 1

# start with pane 1
set -g pane-base-index 1

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

# history
set -g history-limit 4096

# allow terminal scrolling
set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'

# copy paste
bind C-p run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-b run "tmux set-buffer \"$(xclip -o -sel clipboard\"; tmux paste-buffer"

# from system clipboard to tmux
bind-key -n C-P run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# use vi mode
setw -g mode-keys vi
set -g status-keys vi
# setw -g utf8 on

# use mouse in copy mode
set-option -ga terminal-override ',rxvt-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007'
# set -g mode-mouse on

# splitting
unbind %
bind u split-window -h
unbind '"'
bind y split-window -v

# window switching
unbind n
bind = next-window
bind - previous-window
bind -n C-Right next-window
bind -n C-Left previous-window

# colon :
bind : command-prompt

# panes
#set -g mouse-select-pane on
#set -g pane-border-fg colour8 
#set -g pane-active-border-fg colour7 

# toggle statusbar
bind-key b set-option status

# status line
set -g status-justify left
set -g status-bg colour16 
set -g status-fg colour7

#window mode
#setw -g mode-bg colour6
#setw -g mode-fg colour0

# colors 
setw -g window-status-format "#[bg=colour16]#[fg=colour4] -#[bg=colour16]#[fg=colour7] #W  "
setw -g window-status-current-format "#[bg=colour16]#[fg=colour2] -#[bg=colour16]#[fg=colour7] #W  "
#setw -g window-status-current-attr dim
set -g status-position bottom 
set -g status-justify centre 
set -g status-left ' '
set -g status-right ' '

# vim like bindings
bind V send-keys "0v\$"
bind Escape copy-mode
unbind p
bind p paste-buffer

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

# bind -t vi-copy 'v' begin-selection
# bind -t vi-copy 'y' copy-selection
# bind -t vi-copy 'Space' halfpage-down
# bind -t vi-copy 'Bspace' halfpage-up

# chimes 
set-option -g visual-bell off
set-option -g visual-silence off
set-option -g bell-action none

# tmux clock
set -g clock-mode-colour blue

# some key-binding changes
bind x kill-pane
bind X next-layout
bind Z previous-layout
