-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
226 lines (173 loc) · 7.74 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
215
216
217
218
219
220
221
222
223
224
225
226
#
# File: $HOME/.tmux.conf
# Author: Pavol Plaskon, [email protected]
#
# Based on: https://github.com/s3rvac/dotfiles/blob/master/tmux/.tmux.conf
#
# 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.
if-shell "[[ `tmux -V | cut -d' ' -f2` -lt 2.1 ]]" "setw -gq utf8 on"
if-shell "[[ `tmux -V | cut -d' ' -f2` -lt 2.1 ]]" "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
# Create a new window starting in the current working directory rather than in
# the default directory.
bind C new-window -c "#{pane_current_path}"
# 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.
if-shell "[[ `tmux -V | cut -d' ' -f2` -lt 2.4 ]]" \
"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'"
if-shell "[[ `tmux -V | cut -d' ' -f2` -gt 2.3 ]]" \
"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-pipe 'xclip -filter -selection clipboard | xclip -selection primary'"
#------------------------------------------------------------------------------
# Design changes
# Source: http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
#------------------------------------------------------------------------------
## Status bar design
#set -g status-utf8 on
set -g status-justify left
set -g status-bg default
set -g status-fg colour12
set -g status-interval 2
# Messaging
set -g message-style fg=black,bg=yellow
set -g message-command-style fg=blue,bg=black
# Window mode
setw -g mode-style fg=colour0,bg=colour6
# Window status
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W "
setw -g window-status-current-style fg=colour11,bg=colour0,dim
setw -g window-status-style fg=black,bg=green,reverse
# Info on left (I don't have a session display for now)
set -g status-left ''
# Loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
set -g default-terminal "screen-256color"
# The modes {
setw -g clock-mode-colour colour135
setw -g mode-style fg=colour196,bg=colour238,bold
# }
# The panes {
set -g pane-border-style fg=white,bg=colour16
set -g pane-active-border-style fg=green,bg=colour16
# }
# The statusbar {
set -g status-position bottom
set -g status-style fg=colour137,bg=colour234,dim
set -g status-left ''
set -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-style fg=colour81,bg=colour238,bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-style fg=colour138,bg=colour235,none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-style fg=colour255,bg=colour1,bold
# }
# The messages {
set -g message-style fg=colour232,bg=colour166,bold
# }