# prefix
unbind C-b
set -g prefix ^T
bind t send-prefix

# general
set -s escape-time 0
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
set -g history-limit 10000
set -g default-terminal "xterm-256color"
set -g allow-passthrough on
set -g set-clipboard on
set-window-option -g mode-keys vi
set-window-option -g xterm-keys on

# pane/window
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -r C-h resize-pane -L 5
bind -r C-j resize-pane -D 5
bind -r C-k resize-pane -U 5
bind -r C-l resize-pane -R 5
bind K kill-pane
bind c new-window
bind w choose-window
bind C-t run "tmux last-pane || tmux last-window || tmux new-window"

# copy
bind ^y copy-mode
bind -r ^"[" copy-mode
bind p paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi Space send-keys -X begin-selection
if-shell "uname | grep -q Darwin" \
  'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"; bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "pbcopy"'
if-shell 'which xclip' \
  'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel c"; bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -sel c"'

# url open
bind u run-shell "~/.tmux/plugin/urlopen.zsh"

# plugins
run-shell "~/.tmux/plugin/ailog.zsh"

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