# Put the status bar on top
#set -g status-position "top"

# Basic colours, safer for dumb terminals.
#set -g status-style "bg=white,fg=black"
#set -g status-right-style "bg=green,fg=black"
#set -g window-status-current-style "bg=yellow,fg=black"
#set -g message-style "bg=white,fg=black"
#set -g window-status-activity-style "fg=blue"
#set -g window-status-bell-style "fg=red"

## Moar colours! Not recommended if attaching from dumber terminals with 8 or 16 colours.
#set -g default-terminal "tmux-256color"
# A more compatible XTERM var.
set -g default-terminal "screen-256color"
set -g message-style "bg=#485548 fg=#ffffff"
set -g pane-border-style "fg=#424954"
set -g pane-active-border-style "fg=#ffffff"
set -g status-style "bg=#424954 fg=#ffffff"
set -g status-right-style "bg=#303338 fg=colour87"
set -g window-status-current-style "bg=#303338"
set -g window-status-last-style "bg=#364146"
set -g window-status-format ' #I:#W#[fg=colour201]#F '
set -g window-status-current-format ' #[fg=colour226]#I#[fg=#ffffff]:#[fg=colour119]#W#[fg=colour202]#F '
set -g window-status-separator ""

# Uncomment and reload settings for sanity in a console with 8 colours.
#set -g status-style "bg=white,fg=black"
#set -g window-status-last-style "bg=white"

# Might help when graphical characters used for vertical and horizontal lines are drawn as x and q.
#set-option -ga terminal-overrides ',*:enacs@:smacs@:rmacs@:acsc@'

# Count panes starting from 1.
set -g base-index 1

# With this you set the window name in the status line.
# Beware of outrageous prompts, such as the default one in RHEL 7.
set -g set-titles on
# Let status right consists of only the pane title (removes date and time).
# Usually shows current path.
set -g status-right ' #T '
# Increase the default length of 40.
set -g status-right-length 80

# Scroll up with the mouse.
set -g mouse

# Clipboard integration, use this in tandem with the recommended xterm settings.
set -g set-clipboard on
# Pass through modifier keys, xterm style. You'll want this in vim.
set -g xterm-keys on
# Reduce time to wait for Escape key. You'll want this for neovim.
set-option escape-time 40
# Leave ESC alone...
#set-option -s escape-time 0

# New-style mouse scroll (>2.1)
bind -n WheelUpPane   select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \;                 send-keys -M

# This is for scrolling up with the terminal using keys, but has issues...
#set -ga terminal-overrides ',xterm*:smcup@:rmcup@'

# 10x more history.
set -g history-limit 20000

# Swap the default Control-b with Control-s which usually stops the output in a shell.
unbind C-b
set-option -g terminal-overrides "xterm-rightclick:krightclick=^[[29~"
set -g prefix C-s
bind C-s send-prefix

# For renumbering windows when you get gaps in numbering.
bind R                                      \
    move-window -r\;                        \
    display-message "Windows reordered..."

# My shortcuts.
#bind-key -n C-S-t new-window  # Doesn't work :-/
bind-key -n C-t new-window
bind-key -n C-PgUp prev
bind-key -n C-PgDn next
#bind-key -n C-S-PgUp swap-window -t -1  # Doesn't work :-/
#bind-key -n C-S-PgDn swap-window -t +1  # Doesn't work :-/
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
bind-key -n M-` select-window -t 0
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
bind-key -n M-0 select-window -t 10

# switch panes without prefix using Alt-arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# join pane from inputted window (horizontally or vertically)
#bind-key @ command-prompt -p "join pane from:"  "join-pane -s ':%%' -h"
bind-key @ command-prompt -p "join pane from:"  "join-pane -s ':%%' -v"