83 lines
3.4 KiB
Bash
83 lines
3.4 KiB
Bash
# ----------------------------------------------------------------------------
|
|
# Prefix
|
|
# ----------------------------------------------------------------------------
|
|
set -g prefix C-a
|
|
unbind C-b
|
|
bind C-a send-prefix
|
|
bind Tab last-window
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# General behavior
|
|
# ----------------------------------------------------------------------------
|
|
set-option -g set-titles on
|
|
set -g default-terminal "screen-256color"
|
|
set -g history-limit 10000
|
|
set -sg escape-time 1
|
|
set-option -g base-index 1
|
|
setw -g pane-base-index 1
|
|
setw -g aggressive-resize on
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# Windows and panes
|
|
# ----------------------------------------------------------------------------
|
|
bind T swap-window -t 1
|
|
bind | split-window -h -c "#{pane_current_path}"
|
|
bind - split-window -v -c "#{pane_current_path}"
|
|
bind c new-window -c "#{pane_current_path}"
|
|
|
|
bind h select-pane -L
|
|
bind j select-pane -D
|
|
bind k select-pane -U
|
|
bind l select-pane -R
|
|
|
|
# Smart pane switching with awareness of vim splits
|
|
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
|
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
|
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
|
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
|
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
|
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
|
|
|
|
bind -r C-h select-window -t :-
|
|
bind -r C-l select-window -t :+
|
|
|
|
bind a setw synchronize-panes
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# Copy mode and mouse
|
|
# ----------------------------------------------------------------------------
|
|
setw -g mode-keys vi
|
|
set-option -g -q mouse on
|
|
|
|
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'
|
|
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'
|
|
|
|
# tmux renamed the copy-mode key table (vi-copy -> copy-mode-vi) and changed
|
|
# bind-key's table flag (-t -> -T) in 2.4. Source the file matching the
|
|
# running tmux so old tmux never parses syntax it doesn't understand.
|
|
if-shell "tmux -V | awk '{print $2}' | awk -F. '{if ($1*1000+$2 < 2004) exit 0; else exit 1}'" 'source-file ~/.tmux/legacy.conf' 'source-file ~/.tmux/modern.conf'
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# Misc bindings
|
|
# ----------------------------------------------------------------------------
|
|
bind-key C run-shell "cal $(date +%Y)"
|
|
bind r source-file ~/.tmux.conf \; display "Reloaded config"
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# Powerline (guarded so machines without it don't error on load)
|
|
# ----------------------------------------------------------------------------
|
|
run-shell "command -v powerline-daemon >/dev/null 2>&1 && powerline-daemon -q; true"
|
|
run-shell "command -v powerline-config >/dev/null 2>&1 && powerline-config tmux setup; true"
|
|
|
|
# ----------------------------------------------------------------------------
|
|
# Plugins (TPM)
|
|
# ----------------------------------------------------------------------------
|
|
set -g @plugin 'tmux-plugins/tpm'
|
|
set -g @plugin 'tmux-plugins/tmux-sensible'
|
|
|
|
# Local overrides
|
|
if-shell "[ -f ~/.tmux_local.conf ]" 'source ~/.tmux_local.conf'
|
|
|
|
# Initialize TPM (must be the last line)
|
|
run '~/.tmux/plugins/tpm/tpm'
|