# Opciones basicas
set -gs default-terminal "tmux-256color" # Optional
set -gas terminal-overrides "*:Tc"
set -gas terminal-overrides "*:RGB"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
set -g set-titles-string   "#S > #{=-15:?window_name,#{window_name},#{s/corpse/home/:?pane_current_path,#{b:pane_current_path},}} (#T)"
set -g mode-keys            vi
set -g status-keys          emacs
set -g history-limit        102400
set -g display-time         2000
set -sg escape-time         0
set -g set-clipboard        on
set -g mouse                on
set -gq utf8                on
set -gq status-utf8         on
set -g focus-events         on

# Ventanas
set -wg automatic-rename    on
set -g renumber-windows     on
set -g allow-rename         on
set -g base-index           1

# Panes
set -g pane-base-index      1
set -g aggressive-resize    on
set -wg main-pane-width     80

# Notificaciones
set -g monitor-activity     on
set -g bell-action          none

# Limpiar atajos
unbind-key C-b
unbind-key '"'
unbind-key %
unbind-key -
unbind-key Up
unbind-key Down
unbind-key Left
unbind-key Right

# Prefijo
set -g prefix M-a
bind a send-prefix

# Varios
bind-key M     command-prompt -p man: "split-window -fh 'man %1'"
bind-key R     source-file    $XDG_CONFIG_HOME/tmux/tmux.conf \; display "Config Reloaded"

# Dividir
bind-key |     split-window  -h -c "#{pane_current_path}"
bind-key -     split-window  -v -c "#{pane_current_path}"
bind-key ¡     split-window  -fh -c "#{pane_current_path}"
bind-key _     split-window  -fv -c "#{pane_current_path}"

# Cerrar
bind-key x     kill-pane
bind-key X     kill-window
bind-key Z     kill-session
bind-key %     delete-buffer

# Paneles
bind-key (     swap-pane -s :. -t :.- \; select-pane -t :.-
bind-key )     swap-pane -s :. -t :.+ \; select-pane -t :.+
bind-key Up    select-pane -U
bind-key Down  select-pane -D
bind-key Left  select-pane -L
bind-key Right select-pane -R

# Ventanas
bind-key C-p   previous-window
bind-key C-n   next-window
bind-key <     swap-window -t :-1 -d
bind-key >     swap-window -t :+1 -d
bind-key Tab   choose-window
bind-key Enter new-window
bind-key W     choose-tree -Zw "swap-window -t '%%'"
bind-key p     choose-tree -Zw "swap-pane -t '%%'"

# Copy/paste. Seleccionar texto con el mouse lo copia automaticamente al clipboard
bind-key b     list-buffers
bind-key B     choose-buffer
bind-key P     capture-pane -S -32768 \; save-buffer "/tmp/printscreen" \; delete-buffer \; new-window -n "PRINTSCREEN" "$EDITOR /tmp/printscreen"
bind-key -T    copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind-key -T    copy-mode-vi v send-keys -X begin-selection
bind-key -T    copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T    copy-mode-vi y send-keys -X copy-selection-and-cancel

# Statusbar
set -g pane-border-indicators       arrows
set -g set-titles                   on
set -g pane-border-style            bg=default,fg=colour0
set -g pane-active-border-style     bg=default,fg=colour3
set -g mode-style                   fg=colour0,bg=colour100
set -g message-command-style        bg=colour0,fg=colour13
set -g message-style                bg=default,fg=colour7
set -g status-style                 bg=default,fg=colour244
set -g status-right-style           bg=default,fg=colour247
set -g status-justify               right
set -g status-left                  ''
set -g status-right                 " #{pane_title} "
set -g window-status-separator      ' | '
set -g window-status-current-style  bg=default,fg=colour3
set -g window-status-activity-style bg=default,fg=colour14

# vim: set ft=tmux:
