# Custom tmux configuration: ~/.tmux.conf
# Cobbled together from google and experimentation.
# Thx GCU Squad

# screen-like bindings
set -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

# for the lazy c-a c-n/p
bind-key C-n next-window
bind-key C-p previous-window
# _LE_ ^C-a a
bind-key C-a last-window

# on retrouve C-a S/Tab/X 
bind-key | split-window -h
bind-key S split-window -v
bind-key Tab select-pane
bind-key X kill-pane

# set correct term
set -g default-terminal "screen-256color"
set -g history-limit 1000

# Set utf8 and Shell
set-option -g default-shell /bin/bash
set-window-option -g utf8 on
set -g status-utf8 on

# message = quand on accede au 'shell tmux' via C-a :
set -g message-fg red
set -g message-bg default
set -g message-attr bright

# enfin la statusbar, #(foo) affichera la sortie de la commande foo
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set-option -g status-utf8 on
set -g status-left-length 300
set -g status-right-length 1200
set -g status-left '#[fg=green][#[fg=white]#S#[fg=green]][#[fg=white]#(whoami)@#H#[fg=green]][#[default]'
#set -g status-right '#[fg=green]][#[fg=colour33]%Y-%m-%d #[fg=white]%H:%M:%S #(cat /proc/loadavg)#[fg=green]]#[default]'
set -g status-right "#[fg=green]][#[fg=white]Online: #{online_status}|#[fg=red]CPU: #{cpu_icon} #{cpu_percentage}#[fg=white]|#[fg=colour33]%Y-%m-%d #[fg=white]%H:%M:%S#[fg=green]]#[default]"

# Inactive windows in status bar
set-window-option -g window-status-format '#I:#W'
 
# Current or active window in status bar
set-window-option -g window-status-current-format '#[fg=red,bold]#I:#[fg=red]#W#[default]'
 
# Alerted window in status bar. Windows which have an alert (bell, activity or content).
#set-window-option -g window-status-alert-fg white
#set-window-option -g window-status-alert-bg red
#set -g visual-activity on
#set -g visual-bell on
set-option -g status-justify centre

# fix the titles
set -g set-titles on
set -g set-titles-string "#I:#W"

# be notified when there is activity in one of your windows
setw -g monitor-activity on

# rename windows automatically
set-window-option -g automatic-rename on

set -g pane-active-border-bg default

# reload changes in tmux, handy
bind r source-file ~/.tmux.conf
bind b source-file ~/.tmuxperso.conf

# automatic windows
set -g @continuum-restore 'on'

# List of plugins
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins '              \
  tmux-plugins/tpm                 \
  tmux-plugins/tmux-sensible       \
  tmux-plugins/tmux-yank           \
  tmux-plugins/tmux-copycat        \
  tmux-plugins/tmux-online-status  \
  tmux-plugins/tmux-logging        \
  tmux-plugins/tmux-cpu            \
  tmux-plugins/tmux-continuum      \
'
# Other examples:
# github_username/plugin_name    \
# git@github.com/user/plugin     \
# git@bitbucket.com/user/plugin  \

# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'
