# Plugins autoload, load like this  "run-shell path/to/plugin-file.tmux"

# Default shell
set -g default-shell /usr/bin/zsh

# Statusbar-tweaking
set -g status-position top
set -g status-justify right
set -g status-style bg=terminal
set -g status-fg colour15
set -g status-bg terminal 
set -g status-interval 1
set -g status-right-length 10
setw -g window-status-separator ""

# Some other coloring
# Colors for overview and tmux-messages/tmux-enter-the-command prompt
set-window-option -g mode-style bg=terminal,fg=white
set -g message-style bg=terminal,fg=white
# Colors for items in statusbar
setw -g window-status-format "#[bg=terminal,fg=white]#[bg=terminal,fg=white] #I #[bg=terminal,fg=white]#W #[bg=terminal,fg=white]"
setw -g window-status-current-format "#[bg=terminal,fg=black]#[bg=terminal,fg=terminal,bold] #I #[bg=terminal,fg=terminal,nobold]#W #[bg=terminal,fg=black]"
set -g status-justify left
set -g status-right '#[bg=terminal,fg=terminal]#{?client_prefix,  •  ,}'
set-option -g status-left ' '

# Set title for actual terminal-emulator
set -g set-titles on
set -g set-titles-string "#W"

# If running inside tmux ($TMUX is set), then change the status line to red
%if #{TMUX}
set -g status-bg red
%endif

# Enable RGB colour if running in xterm(1)
set-option -sa terminal-overrides ",xterm*:Tc"

# Change the default $TERM to tmux-256color
set -g default-terminal "tmux-256color"

# Scrollback history limit
set -g history-limit 5000

# Set bell/ring enabled
set-window-option -g visual-bell off
set-window-option -g bell-action any

# Don't keep windows around after they exit
set -g remain-on-exit off	

# Count windows from 1
set -g base-index 1
setw -g pane-base-index 1

# Automatically renumber windows when some closes
set -g renumber-windows on

# Pane-border-tweaking
# PWD at the top
set-window-option -g pane-border-status top
set-window-option -g pane-border-format "#[align=left]#[fg=dim]─ #{s|$HOME|~|:pane_current_path} ─"
# Pane-border colors
set -g pane-active-border-style fg=terminal,bold
set -g pane-border-style fg=white,dim,overline

# Change the prefix key to Ctrl-w
set -g prefix C-w
unbind C-b
bind C-a send-prefix

# Turn the mouse on, but without copy mode dragging
set -g mouse on
unbind -n MouseDrag1Pane
unbind -Tcopy-mode MouseDrag1Pane

# Keybinds
# Spawn/kill a pane or window
bind c next-window
bind C new-window -c "#{pane_current_path}"
bind e split -hc "#{pane_current_path}"
bind s split -c "#{pane_current_path}"
bind q kill-pane
bind x kill-window
# Change current tab (window) using alt+1-9 
bind -n M-1 selectw -t:1
bind -n M-2 selectw -t:2
bind -n M-3 selectw -t:3
bind -n M-4 selectw -t:4
bind -n M-5 selectw -t:5
bind -n M-6 selectw -t:6
bind -n M-7 selectw -t:7
bind -n M-8 selectw -t:8
bind -n M-9 selectw -t:9
# Same as previous but for tabs above 9
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
bind F4 selectw -t:13
bind F5 selectw -t:14
bind F6 selectw -t:15
bind F7 selectw -t:16
bind F8 selectw -t:17
bind F9 selectw -t:18
bind F10 selectw -t:19
bind F11 selectw -t:20
bind F12 selectw -t:21
# Enter copy-mode and scroll back
bind -n S-Pageup copy-mode -u
# Hide/show status-bar
bind h set-option status
# Overview-mode
bind t choose-tree -Zs
# Change focus
bind w selectp -t :.+
# Search
bind -n C-M-f copy-mode \; send-key ^S
# Pop-up window
bind p display-popup
# Move panes
bind S-right swap-pane -D
bind S-left swap-pane -U
# Scroll speed
bind -T copy-mode WheelUpPane select-pane \; send-keys -X -N 2 scroll-up
bind -T copy-mode WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
# Keys to toggle monitoring activity in a window and the synchronize-panes option
bind m set monitor-activity
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'

# Create a single default session - because a session is created here, tmux
# should be started with "tmux attach" rather than "tmux new"
new -d -s $USER
