# 		 _
# 		| |_ _ __ ___  _   ___  __
# 		| __| '_ ` _ \| | | \ \/ /
# 		| |_| | | | | | |_| |>  <
# 		 \__|_| |_| |_|\__,_/_/\_\
#
#		by github.com/klewer-martin

# Use prefix + vi navigation keys to navigate panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Start counting windows from 1, to avoid pressing 0 to go to the first one
set -g base-index 1

# Avoid esc delay
set -g escape-time 10

# Enable mouse support
set -g mouse on

set-option -g focus-events on

# More friendly split pane
bind-key / split-window -v
bind-key "'" split-window -h

bind-key \" split-window -h -c "#{pane_current_path}"
bind-key '?' split-window -c "#{pane_current_path}"

bind-key \; last-window

set-option -g history-limit 50000

#source /usr/share/powerline/bindings/tmux/powerline.conf

# Status bar theme
set -g status-bg 'colour233'

set -g status-justify 'left'
set -g status-left-length '65'
set -g status 'on'
set -g status-right-length '100'
setw -g window-status-separator ''

set -g message-command-style fg=black,bg=green
set -g message-style fg=black,bg=cyan
set -g pane-active-border-style fg=colour236
set -g pane-border-style fg=colour236
setw -g window-status-style fg=yellow,none
setw -g window-status-activity-style fg=green,bg=black,none
setw -g window-status-style bg=black


# Status bar style
set -g status-left "#[fg=colour240,bold,bg=colour233] #S  #(echo  '#{pane_current_path}' | shortpath)  #(tmux_status.sh '#{pane_current_path}')"
set -g status-right ''
set -g set-titles on

setw -g window-status-format '#[fg=colour239,bg=colour233,nobold,nounderscore,noitalics] #I #W #F '
setw -g window-status-current-format '#[fg=colour207,bg=colour233,nobold,nounderscore,noitalics] #I #W #F '

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
# bind-key -T copy-mode-vi 'C-\' select-pane -l

set-option -g status-interval 1
set-option -g automatic-rename on

# change \E[?12l to \E[?12h
# set-option -ga terminal-overrides ',xterm-kitty:cnorm=\E[?12h\E[?25h'
