helm/shell/tmux/tmux.conf
2017-12-06 01:39:10 -05:00

183 lines
5.3 KiB
Plaintext

# -- GENERAL -----------------------------
set -g default-terminal screen-256color
set -g default-command $SHELL
# Prevent double-execution of profile, $SHELL needs to be explicitly in profile
# though
set -g default-shell /bin/sh
set -s focus-events on
# increase scrollback buffer size
set -g history-limit 10000
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize off
# Tmux >= 2.1
# enable mouse
setw -g mouse on
# fix mouse scrolling: enter copy mode on scroll-up, exits it when scrolled to bottom
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
# For tmux <2.2
# UTF-8
#set -q -g status-utf8 on
#setw -q -g utf8 on
# Enable mouse
#setw -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
# -- DISPLAY -----------------------------
set -g set-titles on
set -g set-titles-string "tmux [#H] #S:#W:#T"
# Zero-based indexing is fine in programming languages, but not so much in a multiplexer
# when zero is on the other side of the keyboard.
set -g base-index 1
setw -g pane-base-index 1
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
# display tmux messages longer
set -g display-time 1500
set -g display-panes-time 800
# focus events enabled for terminals that support them
set -g focus-events on
# -- KEYBINDS ----------------------------
# set vi keys
setw -g mode-keys vi
setw -g xterm-keys on
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 0
set -sg repeat-time 600
# Custom prefix
set -g prefix C-c
bind C-c send-prefix
# GNU-Screen compatible prefix
# set -g prefix2 C-a
# bind C-a send-prefix -2
unbind C-b
## Pane management
# Saner splitting commands
unbind %
unbind '"'
bind s split-window -c "#{pane_current_path}" -v
bind v split-window -c "#{pane_current_path}" -h
bind c new-window -c "#{pane_current_path}"
# break pane into a window
bind = select-layout even-vertical
bind + select-layout even-horizontal
bind - break-pane
bind _ join-pane
# reload config without killing server
bind r source-file $TMUX_HOME/tmux.conf \; display-message " Config reloaded..".
bind ^r refresh-client
# Smart pane switching with awareness of vim splits
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(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 C-w last-pane
bind C-n next-window
bind C-p previous-window
# Pane resizing
bind C-h resize-pane -L 6
bind C-j resize-pane -D 6
bind C-k resize-pane -U 6
bind C-l resize-pane -R 6
bind -n M-h resize-pane -L 6
bind -n M-j resize-pane -D 6
bind -n M-k resize-pane -U 6
bind -n M-l resize-pane -R 6
# Swap panes directionally
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind H run '$TMUX_HOME/scripts/swap-pane left'
bind J run '$TMUX_HOME/scripts/swap-pane down'
bind K run '$TMUX_HOME/scripts/swap-pane up'
bind L run '$TMUX_HOME/scripts/swap-pane right'
bind M run '$TMUX_HOME/scripts/swap-pane master'
bind o resize-pane -Z
bind S choose-session
bind W choose-window
bind / choose-session
bind . choose-window
bind n run 'TMUX= tmux new-session -t "$(basename \"$PWD\")" -d \; switch-client -t "$(basename \"$PWD\")"'
bind N run 'TMUX= tmux new-session -t "$(tmux display-message -p #S)" -s "$(tmux display-message -p #S-clone)" -d \; switch-client -n \; display-message "session #S cloned"'
# bind = select-layout tiled
bind | select-layout even-horizontal
bind _ select-layout even-vertical
# switch between sessions
bind -r [ switch-client -p
bind -r ] switch-client -n
# Disable confirmation
bind x kill-pane
bind X kill-window
bind q kill-session
bind Q kill-server
# -- COPY MODE ---------------------------
bind Enter copy-mode # enter copy mode
bind b list-buffers # list paster buffers
bind p paste-buffer # paste from the top pate buffer
bind P choose-buffer # choose which buffer to paste from
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line
# -- CUSTOM ------------------------------
if '[[ $OSTYPE == darwin* ]]' 'source $TMUX_HOME/tmux.macos.conf'
source "$TMUX_HOME/tmux.theme.conf" # looks
# Support user overrides
if '[ -f ~/.tmux.conf ]' 'source ~/.tmux.conf'
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @prefix_highlight_fg colour4
set -g @prefix_highlight_output_suffix ' #[bg=colour8] '
# Start plugin manager
run '$TMUX_PLUGINS_HOME/tpm/tpm'