
#################################################
# CONFIG
#################################################

# Fix colors in ANSI-based text editors.
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*col*:Tc"

# Update the status bar every seconds (for the clock).
set -g status-interval 1

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on


#################################################
# SHORTCUTS
#################################################

# Very short Escape key delay, to allow using modal editors.
set -sg escape-time 20

# Remap prefix from 'C-b' to 'C-a'.
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Split panes.
bind s split-window -h
bind S split-window -v
unbind '"'
unbind %

# Windows switching.
bind Tab next-window
bind S-Tab previous-window
bind C-a last-window

# Reload config file.
# NOTE: change file location to your the tmux.conf you want to use.
bind r source-file ~/.tmux.conf


#################################################
# THEME
#################################################

# Design rationale:
# - Basics: visible windows tabs, active one highlighted.
# - This follows the look-n-feel of my generic theming (vim, kakoune, liquidprompt, etc.).
# - Blue is "insert mode", i.e. what you type is typed.
# - Yellow is "normal mode", i.e. the item is a (potential) target for a command.
# - When entering prefix, the active window tab is in yellow.
# - Tabs structure: <window number>(<activity marker><number of panes>)<window position> <window name>
#     - the activity marker is a ‼ if there is a bell alert, a ! if there is a silent notification, a ∘ else.
#     - the window position is a dark ⁚ for the active window, a ⁝ for the last window and a light ⁚ for others.
# - When entering prefix, a yellow [A] is displayed and the active window tab is yellow, drawing attention to what you are doing next.

# Just like a normal window title bar.
set -g status-position top

# Thick blue border.
set -g pane-active-border-style bg='#6f9dfe',fg='#6f9dfe'

# Default status style.
set -g status-style bg='#3f6dce',fg='#d3d0cc'

# tmux-mode-indicator (mainly displays TMUX or WAIT), then prefix marker.
set -g status-left '#{tmux_mode_indicator}#[bg=#3f6dce]#[fg=#d3d0cc]#{?client_prefix,#[bg=#cf8200]#[fg=#f8f8f8][A],[ ]}#[bg=#3f6dce]##[fg=#2f5dbe]║'

# Active window tab.
set-window-option -g window-status-current-format "#{?client_prefix,#[bg=#cf8200],#[bg=#6f9dfe]}#[fg=#ffcc00,bold]❰#[fg=#ffcc00]#I#[fg=#2f5dbe,none](∘#{?client_prefix,#[bg=#cf8200],#[bg=#6f9dfe]}#[fg=#f8f8f8]#{window_panes}#{?client_prefix,#[bg=#cf8200],#[bg=#6f9dfe]}#[fg=#2f5dbe])⁚ #[fg=#ffffff,bold]#W#[fg=#f8f8f8,none]#[fg=#ffcc00,bold]❱"

# Other windows tabs.
set-window-option -g window-status-format "#[bg=#4f7dde,noreverse,bold] #[fg=#cf8200]#I#[fg=#2f5dbe,none](#[fg=#d3d0cc]#{?window_bell_flag,#[bg=#ffcc00]#[fg=#db4939]‼,#{?window_silence_flag,#[bg=#ffcc00]#[fg=#db4939]!,#[fg=#2f5dbe]∘}}#[bg=#4f7dde]#[fg=#d3d0cc]#{window_panes}#[fg=#2f5dbe])#[fg=#d3d0cc]#{last_window}#{?window_last_flag,⁝,⁚} #[fg=#d3d0cc,bold]#W #[fg=#d3d0cc,none]"

# Tabs separator.
set-window-option -g window-status-separator "#[fg=#2f5dbe]║" #⟭⟬"

# No reverse on notifications.
set-window-option -g window-status-activity-style none

# Larger right status section.
set -g status-right-length 50

# download session@host date(week) hour
set -g status-right '↓#{download_speed}#[fg=#2f5dbe]║#[fg=#ffcc00]#S#[fg=#ffffff]@#[fg=#d3d0cc]#h#[fg=#2f5dbe]║#[fg=#d3d0cc]%Y-%m-%d#[fg=#9390bd](#[fg=#d3d0cc]%W#[fg=#9390bd])#[fg=#2f5dbe]║#[fg=#d3d0cc]%H:%M#[fg=#2f5dbe]'


#################################################
# PLUGINS
#################################################

# Plugins
# C-a I to install.
# C-a U to update.
# C-a Alt-u to uninstall.
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# set -g @plugin 'thewtex/tmux-mem-cpu-load' # FIXME does not work
# set -g @plugin 'imomaliev/tmux-keyboard-layout' # FIXME does not work
set -g @plugin 'tmux-plugins/tmux-net-speed'
set -g @plugin 'MunifTanjim/tmux-mode-indicator'
# set -g @plugin 'ofirgall/tmux-window-name'

# tmux-window-name config
# Shell programs, will show dir instead of the program
# set -g @tmux_window_name_shells "['zsh', 'bash', 'sh']"
# Programs that will show the dir name along with the program name.
# set -g @tmux_window_dir_programs "['kak', 'less', 'nvim', 'vim', 'vi', 'git']"

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
