# tmux settings
# http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1#x4f5054494f4e53

# ----------------------------------------------------------------------
# | General Settings                                                   |
# ----------------------------------------------------------------------

# Make a new session, all you need is to run tmux a all the time then
new-session

# Remove delay when sending commands
# (default is 500 milliseconds)
set -sg escape-time 1

# If you want to enable mouse scrolling & cut-n-paste, uncomment the following:
#set -g mouse on
#bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
#bind -n WheelDownPane select-pane -t= \; send-keys -M
#bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
#bind -t vi-copy    C-WheelUpPane   halfpage-up
#bind -t vi-copy    C-WheelDownPane halfpage-down
#bind -t emacs-copy C-WheelUpPane   halfpage-up
#bind -t emacs-copy C-WheelDownPane halfpage-down

set -g history-limit 30000


# ----------------------------------------------------------------------
# | Key Mappings                                                       |
# ----------------------------------------------------------------------

# Make tmux send the PREFIX to an application running
# within tmux simply by pressing PREFIX key twice
bind C-b send-prefix
bind b send-prefix

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Remap the copy & paste keys to work as in vim
unbind [
bind Escape copy-mode

unbind P
bind P paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# [ PREFIX + - ] Split window horizontally
bind - split-window -v

# [ PREFIX + | ] Split window vertically
bind | split-window -h

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# [ PREFIX + h/j/k/l ] Move from pane to pane
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# [ PREFIX + H/J/K/L ] Resize pane
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# [ PREFIX + r ] Reload tmux config
bind r source-file ~/.tmux.conf \; display 'tmux configs reloaded'


# ----------------------------------------------------------------------
# | Status bar                                                         |
# ----------------------------------------------------------------------

# Notified when something happens in one of the other windows
#setw -g monitor-activity on
#set -g visual-activity on

# Periodically refresh the status bar
set -g status-interval 60

# Turn on UTF-8 support
set -g status-utf8 on

# Customize what is displayed
set -g status-justify left
set -g status-left-length 50
set -g status-left " %R | "
#                     └─ current time
set -g status-right " #{prefix_highlight} | #S "
#                     └─ current session name

# ----------------------------------------------------------------------
# | Visual Styling                                                     |
# ----------------------------------------------------------------------

# Display things in 256 colors
set -g default-terminal 'screen-256color'

# Solarized theme
#### COLOUR (Solarized 256)

# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default

# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright

# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01

# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange

# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange

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

# bell
# compatiblity with older tmux versions
#set-window-option -g window-status-bell-style fg=colour235,bg=colour160 #base02, red


# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin "arcticicestudio/nord-tmux"

set -g @continuum-restore 'on'

run '~/.tmux/plugins/tpm/tpm'