forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
122 lines (97 loc) · 5.12 KB
/
tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Set prefix to Ctrl-\
unbind C-b
set -g prefix 'C-\'
bind 'C-\' send-prefix
# 256 colors for vim
set -g default-terminal "screen-256color"
set -ga terminal-overrides ',*:Ss=\eE[%p1%d q:Se=\eE[2 q'
# Start window numbering at 1
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-window-option -g aggressive-resize on
# Cycle panes with C-b C-b
unbind ^B
bind ^B select-pane -t :.+
# Reload config with a key
bind-key r source-file ~/.tmux.conf \; display "Config reloaded!"
# Mouse mode
if-shell "if [[ `tmux -V | cut -d' ' -f2` -lt 2.1 ]]; then true; else false; fi" \
'set -g mode-mouse on; set -g mouse-resize-pane on; set -g mouse-select-pane on; set -g mouse-select-window on'
if-shell "if [[ `tmux -V | cut -d' ' -f2` -ge 2.1 ]]; then true; else false; fi" \
'set -g mouse on; set -g mouse-utf8 on'
# Scrolling works as expected
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# Use the system clipboard
# set-option -g default-command "reattach-to-user-namespace -l bash"
## Clear the pane and it's history
bind -n C-DC send-keys C-l \; clear-history
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
# hit C-\ twice to go to last window
bind-key b set-option status
bind-key / command-prompt "split-window 'exec man %%'"
# 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}"
bind c new-window -c "#{pane_current_path}"
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize panes like vim
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10
# C-l is taken over by vim style pane navigation
bind C-l send-keys 'C-l'
# C-Space to enter copy/scroll mode
bind ] copy-mode
# Use vim keybindings in copy mode
setw -g mode-keys vi
# don't wait for an escape sequence after hitting
# # Esc. fixes insert mode exit lag in vim
set -sg escape-time 0
# Setup 'v' to begin selection as in Vim
# Esc exits select
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
'bind -T copy-mode-vi v send-keys -X begin-selection ; \
bind -T copy-mode-vi C-v send-keys -X rectangle-toggle ; \
bind -T copy-mode-vi y send-keys -X copy-selection ; \
bind -T copy-mode-vi H send-keys -X start-of-line ; \
bind -T copy-mode-vi L send-keys -X end-of-line ; \
bind -T choice-mode-vi h send-keys -X tree-collapse ; \
bind -T choice-mode-vi l send-keys -X tree-expand ; \
bind -T choice-mode-vi H send-keys -X tree-collapse-all ; \
bind -T choice-mode-vi L send-keys -X tree-expand-all ; \
bind -T copy-mode-emacs MouseDragEnd1Pane send-keys -X copy-pipe "pbcopy"; \
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "pbcopy"; ' \
'bind -t vi-copy v begin-selection; \
bind -t vi-copy C-v rectangle-toggle; \
bind -t vi-copy y copy-selection; \
bind -t vi-choice h tree-collapse; \
bind -t vi-choice l tree-expand; \
bind -t vi-choice H tree-collapse-all; \
bind -t vi-choice L tree-expand-all; \
bind -t emacs-copy MouseDragEnd1Pane copy-pipe "pbcopy"; \
bind -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy"; '
# Pane resizing with Ctrl+Alt + arrow
bind -n C-M-Left run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-Left) || tmux resize-pane -L 4"
bind -n C-M-Right run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-Right) || tmux resize-pane -R 4"
bind -n C-M-Up run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-Up) || tmux resize-pane -U 2"
bind -n C-M-Down run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-Down) || tmux resize-pane -D 2"
# Pane resizing with Ctrl+Alt+H/J/K/L
bind -n C-M-H run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-H) || tmux resize-pane -L 4"
bind -n C-M-L run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-L) || tmux resize-pane -R 4"
bind -n C-M-K run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-K) || tmux resize-pane -U 2"
bind -n C-M-J run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-M-J) || tmux resize-pane -D 2"
# Use Powerline
source $SITE_PACKAGES/powerline/bindings/tmux/powerline.conf
# Fix ctrl+alt keys
set-option -g xterm-keys on
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'