# NNTmux Tmux Configuration
# This file is now managed in the config/ directory
# Enhanced with modern styling and powerline fonts

# GNU-Screen compatible prefix
set -g prefix2 C-a
bind C-a send-prefix -2

# Set copy mode to use VI keys - Activates PgUp/PgDn buttons
setw -g mode-keys vi

# Allows for faster key repetition
set -s escape-time 0

# Set 256 color display with true color support
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# Always select window 0 when attaching
set-hook -g client-attached 'select-window -t 0; select-pane -t 0.0'

#==============================================================================
# STATUS BAR - Modern Design with Powerline Symbols
#==============================================================================

# Status bar colors
set -g status-bg colour235
set -g status-fg colour250

# Status bar positioning and update interval
set -g status-position bottom
set -g status-interval 5
set -g status-justify left

# Left status - Session name with powerline arrow
set -g status-left-length 40
set -g status-left "#[fg=colour234,bg=colour39,bold] ❐ #S #[fg=colour39,bg=colour235,nobold]"

# Right status - System info with powerline style
set -g status-right-length 150
set -g status-right "#[fg=colour238,bg=colour235]#[fg=colour250,bg=colour238] #(free -h | grep 'Mem' | awk '{print \"  \"$3\"/\"$2}') #[fg=colour244,bg=colour238]#[fg=colour250,bg=colour244]  #(uptime | cut -d',' -f 3- | sed 's/^ *//;s/ load//')#[fg=colour39,bg=colour244]#[fg=colour234,bg=colour39,bold]  %H:%M %d-%b-%y "

# Window status format
setw -g window-status-format "#[fg=colour244,bg=colour235]  #I:#W  "
setw -g window-status-current-format "#[fg=colour235,bg=colour39]#[fg=colour234,bg=colour39,bold]  #I:#W  #[fg=colour39,bg=colour235,nobold]"

# Window status separator
setw -g window-status-separator ""

#==============================================================================
# PANE BORDERS - Modern rounded style
#==============================================================================

# Pane border colors
set -g pane-border-style fg=colour238
set -g pane-active-border-style fg=colour39

# Pane border format (requires tmux 3.2+)
set -g pane-border-format "#{?pane_active,#[fg=colour39]#[bg=colour235],#[fg=colour238]#[bg=colour235]} #{pane_index} #{pane_title} "
set -g pane-border-status top

#==============================================================================
# MESSAGE STYLING
#==============================================================================

# Command message styling
set -g message-style bg=colour39,fg=colour234,bold
set -g message-command-style bg=colour238,fg=colour250

#==============================================================================
# WINDOW OPTIONS
#==============================================================================

# Constrain window size to the maximum size of any client connected to that window
setw -g aggressive-resize on

# Activity monitoring with visual notification
setw -g monitor-activity on
set -g visual-activity off

# Window status bell styling
setw -g window-status-bell-style fg=colour210,bg=colour235,bold

#==============================================================================
# MOUSE & HISTORY
#==============================================================================

# Enable mouse support
set -g mouse on

# Scrollback line buffer per pane
set -g history-limit 6000

# Keep pane open after process ends - required for monitor.php re-spawns
set -g remain-on-exit on

#==============================================================================
# KEY BINDINGS
#==============================================================================

# Rename pane
bind t command-prompt -p "(rename-pane)" -I "#T" "select-pane -T '%%'"

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

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Switch panes using Alt-arrow without prefix
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

