# ================================
# tmux configuration
# ================================

# General
set -g default-terminal "screen-256color"
set -g escape-time 0
set -g history-limit 10000
set -g mouse on

# Prefix key
unbind C-b
set -g prefix C-a
bind C-a send-prefix

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

# Window navigation
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R

# Pane splitting
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# Pane resizing
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

# Window creation
bind c new-window -c "#{pane_current_path}"

# Copy mode
setw -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode-vi r send-keys -X rectangle-toggle

# Status bar
set -g status-position bottom
set -g status-bg black
set -g status-fg white
set -g status-left-length 40
set -g status-right-length 50

set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-right "#[fg=cyan]%d %b %R"

# Window status
setw -g window-status-current-style fg=black,bg=green
setw -g window-status-style fg=white,bg=black

# Pane borders
set -g pane-border-style fg=black
set -g pane-active-border-style fg=green

# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on

# Start windows and panes at 1
set -g base-index 1
setw -g pane-base-index 1

# Renumber windows when a window is closed
set -g renumber-windows on