This requires no extra config other than what I already have in the base-16-shell. If this is installed then its automatically loaded.
86 lines
2.7 KiB
Bash
86 lines
2.7 KiB
Bash
# split windows like vim
|
|
# vim's definition of a horizontal/vertical split is reversed from tmux's
|
|
bind s split-window -v -c "#{pane_current_path}"
|
|
bind v split-window -h -c "#{pane_current_path}"
|
|
|
|
# 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)?$|emacs'"
|
|
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"
|
|
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
|
|
|
|
#
|
|
# Set color term
|
|
#
|
|
set -g default-terminal "xterm-256color"
|
|
set-option -sg escape-time 10
|
|
set-option -ga terminal-overrides ",tmux-256color:Tc"
|
|
|
|
#
|
|
# Set long history
|
|
#
|
|
set-option -g history-limit 5000
|
|
|
|
# resize panes like vim
|
|
# feel free to change the "1" to however many lines you want to resize by, only
|
|
# one at a time can be slow
|
|
bind < resize-pane -L 1
|
|
bind > resize-pane -R 1
|
|
bind - resize-pane -D 1
|
|
bind + resize-pane -U 1
|
|
|
|
# Setup window switching via fzf
|
|
bind-key f run-shell -b ~/.local/bin/tmux-switch-pane
|
|
|
|
# bind : to command-prompt like vim
|
|
# this is the default in tmux already
|
|
bind : command-prompt
|
|
|
|
# vi-style controls for copy mode
|
|
setw -g mode-keys vi
|
|
|
|
# set windows so they dont resize to the smallest
|
|
setw -g aggressive-resize on
|
|
|
|
# use mouse on
|
|
set -g mouse on
|
|
set-option -g mouse on
|
|
|
|
set -g @open-S 'https://www.duckduckgo.com/'
|
|
set -g @open-editor-command 'emacs --no-wait'
|
|
|
|
# Init plugins
|
|
run-shell ~/.tmux/plugins/tmux-copycat/copycat.tmux
|
|
run-shell ~/.tmux/plugins/tmux-open/open.tmux
|
|
run-shell ~/.tmux/plugins/tmux-yank/yank.tmux
|
|
|
|
# Automatically renumber window numbers on closing a pane (tmux >= 1.7).
|
|
set -g renumber-windows on
|
|
|
|
# Stay in copy mode on drag end.
|
|
# (Would use `bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X
|
|
# stop-selection` but it is a bit glitchy.)
|
|
unbind-key -T copy-mode-vi MouseDragEnd1Pane
|
|
|
|
# Search back to last prompt.
|
|
bind-key b copy-mode\; send-keys -X start-of-line\; send-keys -X search-backward "⇒"\; send-keys -X next-word
|
|
|
|
# Set `v` key to start selection like vim
|
|
bind-key -T copy-mode-vi 'v' send -X begin-selection
|
|
|
|
# Start window and pane numbering at 1, (0 is too hard to reach).
|
|
set -g base-index 1
|
|
set -g pane-base-index 1
|
|
|
|
# Needed as on tmux 1.9 and up (defaults to off).
|
|
# Added in tmux commit c7a121cfc0137c907b7bfb.
|
|
# Also need by vim plugin tmux-focus-events.vim
|
|
set -g focus-events on
|
|
|