# set command prefix for tmux
set-option -g prefix C-a
unbind C-a

# set default shell to zsh
set-option -g default-shell /bin/bash
set -g default-terminal screen-256color

# 0 is too far from ` ;)
set -g base-index 1

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

setw -g mode-keys vi
setw -g mouse on
setw -g monitor-activity on

bind-key v split-window -h
bind-key s split-window -v

bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5

bind-key M-j resize-pane -D
bind-key M-k resize-pane -U
bind-key M-h resize-pane -L
bind-key M-l resize-pane -R

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R

# Use Alt-arrow keys without prefix key to switch panes
bind -n C-M-Left select-pane -L
bind -n C-M-Right select-pane -R
bind -n C-M-Up select-pane -U
bind -n C-M-Down select-pane -D

# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# Swap Windows
bind -n C-S-Left { swap-window -t -1; previous-window }
bind -n C-S-Right { swap-window -t +1; next-window }

# No delay for escape key press
set -sg escape-time 0

# bind a reload key
bind W                                      \
    set -g renumber-windows on\;            \
    new-window\; kill-window\;              \
    set -g renumber-windows off\;           \
    display-message "Windows reordered..."

bind R \
    source-file ~/.tmux.conf \; display-message "  Config reloaded..".
# Reload tmux config
# bind r source-file ~/.tmux/tmux.conf

# THEME
# set -g status-style fg=white,bg=#3a3a3a
# set -g status-interval 15
# set -g status-left-length 30
# set -g status-right-length 90
# set -g status-left '#[fg=#00ffff](#S)#(whoami) '
# set -g status-right '#[#(gitmux "#{pane_current_path}") #[fg=blue]%Y-%m-%d#[default] #[fg=green]%H:%M#[default]'

# Define my custom menu bar
  # status bar colors
  set -g status-bg white

  # alignment settings
  set-option -g status-justify centre

  # status left options
  set-option -g status-left '"#[fg=black]#S#[default]"'
  set-option -g status-left-length 20

  # window list options
  setw -g automatic-rename on
  set-window-option -g window-status-format '#[fg=black]#I#[fg=black]:#[fg=black]#W#[fg=black]'
  set-window-option -g window-status-current-format '#[bg=green][X]:#[bg=green]#[bg=green]#W#[bg=green]#F'
  set -g base-index 1

  # status right options
  set -g status-right '#(gitmux -cfg $HOME/.gitmux.conf "#{pane_current_path}") #[default]%H:%M#[default]#[default]::#[default]%d.%m.%y'
  set -g status-right-length 0