-
Notifications
You must be signed in to change notification settings - Fork 9
/
dot_tmux.conf
167 lines (135 loc) · 5.7 KB
/
dot_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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Set the command prefix
set -g prefix C-a
unbind C-b
unbind C-c
# Remove time delay to avoid tripping vi
set -s escape-time 1
# synchronize-panes shortcut
bind y set-window-option synchronize-panes
# Ensure 0-based index for window numbers
set -g base-index 0
# Ensure 0-based index for pane numbers
set -g pane-base-index 0
# Make it a little easier for new tmux users
set -g mouse on
# Reloads the config file
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Send prefix to an application by pressing the prefix twice
bind C-a send-prefix
# Window splitting
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
#
# BEGIN Adapted from https://stackoverflow.com/a/40902312
#
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | sed -E "s/^tmux +([\.0-9]+).*/\1/g")'
# NOTE: tmux doesn't use SemVer. It just increments by 0.1 with every release.
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' ' \
bind-key \ split-window -h -c "#{pane_current_path}"'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' ' \
bind \\ split-window -h -c "#{pane_current_path}"'
#
# END
#
# Smart pane switching with awareness of Vim splits and fzf.
# See: https://github.com/junegunn/fzf/pull/582#issuecomment-377731826
# Tip:
# Get the tty and index of all the panes in the current window by running
# the following command in the shell:
#
# tmux list-panes -F '#{pane_tty} #{pane_index}'
#
# Then run the following command to get the stach of commnands running in
# the pane you are insterested in:
#
# ps -o state= -o comm= -t '<TYPE_YOUR_PANE_TTY_HERE>'
#
one_of_apps="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?(g?(view|n?vim?x?)(diff)?|fzf|meteor)$'"
bind -n C-h if-shell "$one_of_apps" "send-keys C-h" "if -F '#{pane_at_left}' '' 'select-pane -L'"
bind -n C-j if-shell "$one_of_apps" "send-keys C-j" "if -F '#{pane_at_bottom}' '' 'select-pane -D'"
bind -n C-k if-shell "$one_of_apps" "send-keys C-k" "if -F '#{pane_at_top}' '' 'select-pane -U'"
bind -n C-l if-shell "$one_of_apps" "send-keys C-l" "if -F '#{pane_at_right}' '' 'select-pane -R'"
bind -n 'C-\' if-shell "$one_of_apps" "send-keys 'C-\\'" "select-pane -l"
# Old-style pane movement. For when you want to move between panes immediately
# and not have to pass through one or more Vim splits.
bind h select-pane -L
# Sometimes, I press h too soon before I've let go of Ctrl (Which is part of
# the prefix combo). During those instance, this ensures my intent is still
# understood by tmux.
bind C-h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Sometimes, I press l too soon before I've let go of Ctrl (Which is part of
# the prefix combo). During those instance, this ensures my intent is still
# understood by tmux.
bind C-l select-pane -R
# Smart pane resizing with awareness of Neovim splits.
# In iTerm2 you'll need to go to Preferences > Profile > Keys > Key Mappings
# and map Command-{h,j,k,l} as Escape sequence {h,j,k,l} respectively
bind -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'resize-pane -L 3'
bind -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'resize-pane -D 3'
bind -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'resize-pane -U 3'
bind -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'resize-pane -R 3'
# Old-style pane resizing. For when you want to resize a pane immediately and
# not have to pass through one or more Vim splits.
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# # Display things in 256 colors
set -g default-terminal "screen-256color"
# Set status bar color scheme
set -g status-bg colour235
set -g status-fg white
set -g window-status-style fg=colour248,bg=colour235
set -g window-status-current-style bg=colour253,fg=colour232,bright
# Set pane colors
set -g pane-border-style fg=colour236
set -g pane-active-border-style fg=colour142
# Set the status bar information
set -g status-left-length 40
set -g status-left "#[fg=colour248]S:#S W:#I P:#P#{?pane_synchronized, #[fg=colour255]#[bg=red](synced)#[default],}"
set -g status-right "#[fg=colour248]%b %d %R"
# set utf-8 support in the status bar
if-shell "[[ `tmux -v | cut -d' ' -f2` -le 2.0 ]]" \
"set -g status-utf8 on"
# Set status bar refresh interval
set -g status-interval 60
# Set window list alignment
set -g status-justify centre
# Set window notifications
setw -g monitor-activity on
setw -g visual-activity on
# Enable vi mode
setw -g mode-keys vi
# Make copy/paste same as vim
# unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
unbind-key -T copy-mode-vi v
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection-and-cancel
# Integrate with OS X pasteboard
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Disable auto-rename of windows
set-option -g allow-rename off
# Increase scrollback history
set-option -g history-limit 10000
# Experimental: popup session selector
# From https://waylonwalker.com/tmux-fzf-session-jump/
bind C-u display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# Tmux plugins managed by Tmux Plugin Manager
# See: https://github.com/tmux-plugins/tpm
set -g @plugin 'tmux-plugins/tpm'
# Fuzzy find text to copy (uses fzf)
# See: https://github.com/laktak/extrakto
set -g @plugin 'laktak/extrakto#efca89800293cbb8224463d82eeecffdb2f7036a'
# Automatically renumber windows when one closes.
# Can be overriden by a session.
set-option -g renumber-windows on
# This MUST ALWAYS be at the bottom of the file
run '~/.tmux/plugins/tpm/tpm'