#  ██████████ ████     ████ ██     ██ ██     ██
# ░░░░░██░░░ ░██░██   ██░██░██    ░██░░██   ██
#     ░██    ░██░░██ ██ ░██░██    ░██ ░░██ ██
#     ░██    ░██ ░░███  ░██░██    ░██  ░░███
#     ░██    ░██  ░░█   ░██░██    ░██   ██░██
#     ░██    ░██   ░    ░██░██    ░██  ██ ░░██
#     ░██    ░██        ░██░░███████  ██   ░░██
#     ░░     ░░         ░░  ░░░░░░░  ░░     ░░
#
#  ▓▓▓▓▓▓▓▓▓▓
# ░▓ Author ▓ AK <abdullah@abdullah.today>
# ░▓▓▓▓▓▓▓▓▓▓
# ░░░░░░░░░░

# source powerline 
# source /usr/lib/python3.8/site-packages/powerline/bindings/tmux/powerline.conf

# Custom Prefix
unbind C-b
set-option -g prefix `
bind ` send-prefix

# Shell
set -g default-command /bin/zsh
set -g default-shell /bin/zsh

# Reload the config
bind r source-file ~/.config/tmux/tmux.conf \; display "configuration file reloaded"

# Synchronize panes
bind e setw synchronize-panes \; display "synchronize mode"

# Splits
unbind %
unbind '"'
bind b split-window -v
bind v split-window -h

# Panes numbers
set -g display-panes-active-colour colour20
set -g display-panes-colour colour196

# enable vi-mode
setw -g mode-keys vi
set -g status-keys vi

# copy paste
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

# command mode
bind : command-prompt

# Kill panes
bind x kill-pane

# Toggle Status 
bind t set status

# Lock the tty

bind z run-shell "/usr/bin/physlock -dmp 'you cant run this system fuckin looser'"

# music player

bind o run-shell "mpc toggle >/dev/null 2>&1"

# Alerts
setw -g monitor-activity on
set -g visual-activity on

# Enable mouse mode
setw -g mouse on
setw -qg mode-mouse on
set -qg mouse-select-pane on
set -qg mouse-resize-pane on
set -qg mouse-select-window on
set -qg mouse-utf8 on
set -qg mouse on

# Default terminal mode
set -g default-terminal 'tmux-256color'
set -sa terminal-overrides ',xterm-256color:RGB'

# Status and colors
set -g status on
set -g status-justify left
set -g status-interval 2
set -qg status-utf on
set -g status-style fg=colour130,bg=colour235
setw -g automatic-rename on
setw -g window-status-style bg=default,fg=colour33
setw -g window-status-current-style bg=default,fg=colour196
 
# HJKL / vi-like pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes
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

# Right status
set -g status-right-length 150
set -g status-right  '#(~/.local/bin/tmux-status)'
set -g status-left-length 75
set -g status-left ''

# Visuals
setw -g monitor-activity off
set-option -g bell-action none
set-option -g visual-activity on
set-option -g visual-bell off
set-option -g visual-silence off

# clock
set -g clock-mode-colour colour20

# urlview
run-shell $HOME/.local/bin/tmux.urlview

# resize panes
setw -g aggressive-resize on

# No delay
set -sg escape-time 0

# History
set -g history-limit 10000

# Scrolling
set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'

# Panes index
set -g pane-base-index 1
set -g renumber-windows on

# Pane numbers
set -g display-panes-active-colour colour20
set -g display-panes-colour colour196

# Pane borders
# set-option -g pane-border-fg colour235 
# set-option -g pane-active-border-fg colour46
set -g pane-border-style fg=green,bg=black
set -g pane-active-border-style fg=white,bg=yellow

# Windows index
set -g base-index 1

# Layouts
bind Z previous-layout
bind X next-layout

# Detach others
bind D detach -a

# Update environments
set -g update-environment "DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_AUTH_SOCK XAUTHORITY"

# Message text
set -g message-style bg=colour235,fg=colour196
