set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

set-option -s set-clipboard on
set -sg escape-time 0
set -g bell-action other
set -g lock-after-time 1800
set -g lock-command 'tput civis && read -s -n1'
set -g history-limit 10000
set -g default-terminal "screen-256color"
set -g pane-border-style fg=white,bg=default
set -g pane-active-border-style fg=red,bg=default
set -g repeat-time 100
set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@:Tc"

#set -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,rxvt-uni*:Tc:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]12;green\007:Cs=\E]777;Cs;%p1%d\007'
set -g mouse on
set -g status-style bg=blue,fg=cyan

set-hook -g alert-bell 'run -b "notify-send \"Bell in session #{session_name}:#{window_index}:#{window_name}\""'

unbind-key /
unbind-key c 
unbind-key d 
unbind-key f
unbind-key i 
unbind-key l 
unbind-key n 
unbind-key o 
unbind-key p 
unbind-key r 
unbind-key s 
unbind-key t 
unbind-key w
unbind-key x 
unbind-key |
unbind-key -
unbind-key A
unbind-key S
unbind-key .
unbind-key "'"
unbind-key '#'
unbind-key ' '
unbind-key z
unbind-key ^z

bind a send-prefix
bind c new-window -a -c '#{pane_current_path}'
bind d detach-client
bind "/" command-prompt "find-window '%%'"
bind i display-message
bind a last-window
bind n next-window
bind o select-pane -D
bind p previous-window
bind r respawn-window
bind s choose-tree -Z
bind t clock-mode
bind w choose-window
bind k confirm-before kill-pane
bind x set lock-command '/usr/bin/vlock' \; lock-client \; set lock-command 'tput civis && read -s -n1'
bind "|" split-window -v -c '#{pane_current_path}'
bind "-" split-window -h -c '#{pane_current_path}'
bind l command-prompt "rename-window '%%'"
bind S command-prompt "rename-session '%%'"
bind . display-panes
bind "'" command-prompt -p "SSH: " "new-window -n %1 'ssh %1'"
bind ' ' choose-window
bind z resize-pane -Z

bind ^a last-window 
bind ^c new-window -a -c '#{pane_current_path}'
bind ^d detach-client
bind ^i display-message
bind a last-window
bind ^n next-window
bind ^o select-pane -D
bind ^p previous-window
bind ^r respawn-window
bind ^s choose-session
bind ^t clock-mode
bind ^w choose-window
bind ^k confirm-before kill-pane
bind ^x lock-client
bind ^S command-prompt "rename-session '%%'"
bind ^z resize-pane -Z

bind -n C-Left previous-window
bind -n C-Right next-window
bind -n C-s set status

bind -r C-Left swapw -t:-
bind -r C-Right swapw -t:+

# Status stuff.
set -g status-left-style "fg=white, bg=magenta"
set -g status-left-length 30
set -g status-left "#S "
set -g status-right-length 30
set -g status-right-fg white
set -g status-right-bg blue
set -g status-right "#{?client_prefix,#[reverse][^a]#[noreverse],}[%a %d/%m %H:%M]"
set -g display-panes-time 4000
set -g window-status-bell-style reverse

#setw -g window-status-current-fg white
#setw -g window-status-current-bg colour34
setw -g mode-keys vi

setw -g window-status-separator "| "
#setw -g window-status-format "#[bg=blue]#I:#W:#{window_flags}#[bg=default]"
#setw -g window-status-current-format "#[fg=black,bg=green]#I:#W:#{window_flags}"

setw -g window-status-format "#[bg=blue]#I:#W:#{?window_linked,+#{window_flags},#{window_flags} }#[bg=default]"
setw -g window-status-current-format "#[fg=black,bg=green]#I:#W:#{?window_linked,+#{window_flags},#{window_flags}}"

set-window-option -g clock-mode-colour green

# Sessions
new -d -sspecial
new -d -swork -d -nmutt 'exec neomutt'
neww -d
neww -d
neww -d
neww -d

# FIXME -- the entire block below is required for taskwarrior.
#new -d -stask -ntask -x237 -y 79
#selectl -ttask tiled
#set -ttask status off
#splitw -ttask:task
#splitw -ttask:task
#splitw -ttask:task
#splitw -ttask:task
#splitw -ttask:task
#selectl -ttask:task 4ada,237x79,0,0[237x67,0,0{156x67,0,0,5,80x67,157,0[80x27,157,0,19,80x22,157,28,20,80x16,157,51,21]},237x11,0,68,22]
#send -ttask:task.0 'cyclenext list' 'C-m'
#send -ttask:task.1 'clear ; tasksh' 'C-m'
#send -ttask:task.2 'cyclenext summary' 'C-m'
#send -ttask:task.3 'cyclenext burndown.daily' 'C-m'
#send -ttask:task.4 'cyclenext ghistory.monthly' 'C-m'
#selectp -ttask:task.1
#linkw -stask:task -twork
#set -t task:task remain-on-exit on

set -t work:irc remain-on-exit on
set -t work:mutt remain-on-exit on
