-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
214 lines (165 loc) · 7.37 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#------------------------------------------------------------------------------
# File: $HOME/.tmux.conf
# Author: Petr Zemek <[email protected]>
#------------------------------------------------------------------------------
# Rebind the prefix from C-b to C-Space.
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
#------------------------------------------------------------------------------
# Settings.
#------------------------------------------------------------------------------
# Support 256 colors in the terminal emulator.
set -g default-terminal "screen-256color"
# Disable the delay between an escape key press and subsequent characters.
# This increases Vim responsiveness.
set -sg escape-time 0
# Set the base index for windows to 1 instead of 0.
set -g base-index 1
# Set the base index for panes to 1 instead of 0.
setw -g pane-base-index 1
# Scrollback limit.
set -g history-limit 10000
# Enable terminal-emulator scrolling.
set -ga terminal-overrides ",xterm*:smcup@:rmcup@"
# Pass xterm-style keys to make key combinations work as expected.
setw -g xterm-keys on
# Disable mouse in tmux. This makes tmux pass control directly to the used
# terminal emulator, so I can copy&paste as if I am not using tmux.
# tmux < v2.1:
if-shell "[[ `tmux -V | cut -d' ' -f2` -lt 2.1 ]]" "setw -g mode-mouse off"
# tmux >= v2.1:
if-shell "[[ `tmux -V | cut -d' ' -f2` -ge 2.1 ]]" "setw -g mouse off"
# Monitor window activity. Windows with activity are then highlighted in the
# status line.
setw -g monitor-activity on
# Prevent tmux from displaying "Activity in window X" messages.
set -g visual-activity off
# Enable vi keys.
set -g status-keys vi
setw -g mode-keys vi
# Enable utf-8. Only available in tmux < v2.2.
setw -gq utf8 on
set -gq status-utf8 on
# Enable setting of terminal-emulator titles.
set -g set-titles on
set -g set-titles-string "#h"
# Automatically re-number windows after one of them is closed.
set -g renumber-windows on
#------------------------------------------------------------------------------
# Key Bindings.
#------------------------------------------------------------------------------
# Smart pane switching with awareness of Vim splits. Now, I can use Ctrl+hjkl
# in both Vim and Tmux (without using the prefix). Based on
# http://www.codeography.com/2013/06/19/navigating-vim-and-tmux-splits.
# Note: I do not use https://github.com/christoomey/vim-tmux-navigator because
# it does not work when vim is run over ssh.
# Note: The "... || true" part is there to prevent annoying messages when there
# is no pane to switch into.
# bind -n C-h run "(tmux display-message -p '#{pane_title}' | grep -iq vim && tmux send-keys C-h) || (tmux select-pane -L || true)"
# bind -n C-j run "(tmux display-message -p '#{pane_title}' | grep -iq vim && tmux send-keys C-j) || (tmux select-pane -D || true)"
# bind -n C-k run "(tmux display-message -p '#{pane_title}' | grep -iq vim && tmux send-keys C-k) || (tmux select-pane -U || true)"
# bind -n C-l run "(tmux display-message -p '#{pane_title}' | grep -iq vim && tmux send-keys C-l) || (tmux select-pane -R || true)"
# Occasionally, it may happen that the above smart-pane-switching keys do not
# work. In such a case, the following bindings allow me to force pane switching
# by using Ctrl+hjkl with prefix.
bind C-h select-pane -L
bind C-j select-pane -D
bind C-k select-pane -U
bind C-l select-pane -R
# Pane resizing.
bind -r M-h resize-pane -L 5
bind -r M-j resize-pane -D 5
bind -r M-k resize-pane -U 5
bind -r M-l resize-pane -R 5
# Pane splitting.
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Movement of windows.
bind -r < swap-window -t -1
bind -r > swap-window -t +1
# Make the prefix and 0 go to window number 10 (I use window numbering starting
# from 1).
bind 0 select-window -t :10
# Do not display the original window's name when renaming it. This makes
# renaming faster since one does not need to first erase the original name.
bind , command-prompt -p "(rename-window '#W')" "rename-window '%%'"
# Do the same for sessions.
bind '$' command-prompt -p "(rename-session '#S')" "rename-session '%%'"
# Make f search only in window names (-N), not in titles (-T) or contents (-C).
# The default is -CNT.
bind f command-prompt -p "(find-window)" "find-window -N '%%'"
# Clear activity flags from all windows in the current session.
# Based on http://stackoverflow.com/a/12670429/2580955.
# Note: The 'tmux-select-each' script has to be available in $PATH.
bind Space run-shell "tmux-select-each '#S'"
# Configuration file reload.
bind R source-file ~/.tmux.conf \; display "Configuration reloaded."
# Toggle pane synchronization.
bind S set synchronize-panes
# Make b start copy mode.
# bind b copy-mode
# Make Ctrl+b start copy mode and scroll one page up (just like PgUp does).
# bind C-b copy-mode -u
# Make copy mode behave more like Vim.
# Moreover, make 'y' copy also to the system clipboard.
# bind -t vi-copy v begin-selection
# bind -t vi-copy C-v rectangle-toggle
# bind -t vi-copy y copy-pipe "xclip -filter -selection clipboard | xclip -selection primary"
#------------------------------------------------------------------------------
# Styling.
#------------------------------------------------------------------------------
# Status line.
set -g status-fg white
set -g status-bg black
set -g status-left ""
set -g status-right "#{?pane_synchronized, #[bg=blue]SYNCHRONIZED#[default],} #S #(wemux status_users)"
# Window list.
# setw -g window-status-fg colour246 # grey
# setw -g window-status-bg black
# setw -g window-status-attr dim
setw -g window-status-format "#[fg=colour172]#I#[fg=white] #W "
# Active window.
# setw -g window-status-current-fg white
# setw -g window-status-current-bg black
# setw -g window-status-current-attr bright
setw -g window-status-current-format "#[fg=colour172]#I#[fg=white] #W#F"
# Window activity.
# setw -g window-status-activity-fg colour246 # grey
# setw -g window-status-activity-bg black
# Panes.
# set -g pane-border-fg white
# set -g pane-border-bg black
# set -g pane-active-border-fg green
# set -g pane-active-border-bg black
# Command/message line.
# set -g message-fg white
# set -g message-bg black
# set -g message-attr bright
# Status update interval.
set -g status-interval 60
# Make the window list appear at the left-hand side instead of at the center.
set -g status-justify left
#------------------------------------------------------------------------------
# Plugins.
#------------------------------------------------------------------------------
# https://github.com/tmux-plugins/tmux-copycat
# I have to use Alt-s for SHA-1 searches because I use Alt-h (the default) to
# resize the current pane.
set -g @copycat_hash_search "M-s"
# Make Ctrl-p search for the last occurrence of a prompt. See my .bashrc for a
# description of the prompt format.
set -g @copycat_search_C-p "[0-9]+:[0-9]+ .*@.* \\\$ "
run-shell ~/.tmux/plugins/tmux-copycat/copycat.tmux
# https://github.com/tmux-plugins/tmux-open
run-shell ~/.tmux/plugins/tmux-open/open.tmux
# tmuxinator pane index
set-window-option -g pane-base-index 1
# from copy mode, press y instead of enter to copy to the X clipboard rather than tmux's
# bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'
# Fix vim colours
set-option -sa terminal-overrides ',xterm-256color:RGB'
# Fix vim autoread
set-option -g focus-events on
# for image.nvim we enable passthrough
set -gq allow-passthrough on