# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'

# enable mouse support
set -g mouse on
# ... and enable mouse mode toggling
bind m run "\
    tmux show-options -g | grep -q \"mouse on\";\
    if [ \$? -eq 0 ];\
        then toggle=off;\
    else\
        toggle=on;\
    fi;\
    tmux display-message \"mouse is now: \$toggle\";\
    tmux set-option -g mouse \$toggle;"

# required for vim-clipboard integration
set -g focus-events on

# allow scroll while in input mode
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

# try to use correct colors
set -g default-terminal screen-256color

# reload tmux config
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"

# rebind some clear history command
bind C-l send-keys C-l \; clear-history

# 500k lines of history...
set-option -g history-limit 500000

# reuse directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

# Use vim keybindings in copy mode
set-window-option -g mode-keys vi
unbind -T copy-mode-vi MouseDragEnd1Pane
bind-key -T copy-mode-vi y send-keys -X copy-selection

# prevent delayed escape key
set -s escape-time 0

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