-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdot.tmux.conf
267 lines (225 loc) · 9.69 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
################################################################
# NC notes
# Multiple views into same set of windows. If you attach (`tmux a`) to
# the same session twice, then both views are the same: if you change
# the current window/pane (I don't know the terminology yet) in one
# attachment then view in the other attachment changes also. The
# solution, to get screen-like behavior of separate views, is to
# create a new sesssion:
#
# $ tmux new-session -t <number or name of old session, default 0 for first session>
#
# where `tmux ls` will list existing sessions.
#
# Source:
# http://unix.stackexchange.com/questions/24274/attach-to-different-windows-in-session
# Some things that surprised me:
#
# - tmux shares global state between all sessions on the same tmux
# server, and the tmux server is automatically created for each
# user, for the first tmux session they start. You can override this
# by creating a new socket for your new session using 'tmux -L
# <name>' or 'tmux -S <path>', and then running tmux the same way
# for all subsequent commands related to this session. One symptom
# of the reused sessions is the environment used by tmux for new
# shells is the one in effect when the server was created, not the
# one in effect when the session was created (the oppossite of what
# I want).
#
# - tmux uses login shells by default in each new pane, and login
# shells do path manipulation and perhaps other env
# manipulation. You can override tmux to use regular shells -- and
# hence get less environment disruption -- by setting
# 'default-command' to '$SHELL' in this config file, see below.
################################################################
# NC Keybindings
# My leader (L) is C-o.
#
# - L-z: zoom a pane to full screen, or revert a zoomed pane. Useful
# before copying with mouse when panes are split with vertical line.
#
# - L-q: show pane numbers on panes. Hitting a number before they
# disappear -- I changed the delay to 5 seconds below -- will jump
# to that pane.
#
# - L-<space>: cycle layouts.
#
# - L-<alt>-<n>: switch to layout <n>. There are 5 layouts by default:
#
# - L-/: enter copycat mode, which is copy mode with search
# highlighting and regexp support. Docs with other key bindings:
# https://github.com/tmux-plugins/tmux-copycat.
#
# - L-I: install plugins.
################################################################
# NC additions
# Plugin for better copy mode. In particular, it highlights search
# results.
#
# Use L-/ to start a copy cat search. Could rebind L-[, which
# currently points to regular copy mode, to point to copycat instead
# ...
set -g @plugin 'tmux-plugins/tmux-copycat'
# Use shift-<direction> to change panes, as in Emacs.
#
# The '-n' means "don't require the leader (C-o) to be pressed first".
bind -n S-Up select-pane -U
bind -n S-Down select-pane -D
bind -n S-Left select-pane -L
bind -n S-Right select-pane -R
# Time in milliseconds that numbers for `display-panes` are
# displayed. The shortcut for `display-panes` is `<leader> q`. Use
# `<esc>` to cancel display if you don't want to change panes.
set -g display-panes-time 5000
# Colors.
#
# See docs for `message-command-style` for allowed colors. E.g. there
# is no "purple", but there is "magenta".
set -g display-panes-colour magenta
set -g display-panes-active-colour green
# Border colors.
set -g pane-border-style fg=green,bg=default
set -g pane-active-border-style fg=red,bg="#444444",bold
# Fix reverse video (e.g. for highlighting in `less`):
# http://superuser.com/a/891337/73337.
set -g terminal-overrides 'rxvt-unicode*:sitm@,ritm@'
# Default for the `TERM` env var. Setting to `screen-256color` causes
# problems for Emacs: search results longer than two characters are
# hidden, and almost everything is red?!?
#
# Inside Emacs, running `list-colors-display` will show you how many
# colors you have. Outside of Tmux I get a smooth gradient of hundreds
# of colors. Inside Tmux, with `screen-256color` set below I get a
# long list with many repeats, and with `screen` set below I get a
# short list. But neither of them look like the list outside of Tmux.
#
# I ended up with `rxvt-unicode` which has lots of repeated Emacs
# colors like `screen-256color`, but doesn't have the Emacs
# highlighting problem.
#
# WARNING: this setting doesn't seem to take effect until you exit all
# tmuxen you have running!
#
# WEIRDNESS: if I run `tmux -2` instead, to force 256 color mode, then
# I get mostly perfect colors in `emacs -nw`. E.g. Haskell mode
# highlighting is good, and the output of `M-x list-colors-display` is
# a smooth gradient. However, the box around the active window in the
# tmux status bar at the bottom disappears, and in Emacs some fonts
# are too dark to read (it uses dark blue for the mini-buffer).
set -g default-terminal rxvt-unicode
# Resize window to size of current viewer when only one viewer is
# active: https://mutelight.org/practical-tmux.
#
# By default, when two sessions are attached to the same window set
# (no idea what the right terminology is: I mean, when you do `tmux -s
# s1` and then `tmux -s s1 -t s2` to make session s1 and s2 point to
# the same windows), the size of the visible window is determined by
# the smallest of the sessions currently attached. In XMonad, when you
# switch from a split view to a full screen view, tmux keeps the
# window half size until all sessions attached to the window have been
# brought to the front. This option changes that: the window is
# resized each time a session views it, as long as no other session is
# also focusing on it (but you rarely point two sessions at the same
# window at the same time ...).
setw -g aggressive-resize on
# Show process/title for all panes in each window.
set -g pane-border-status bottom
################################################################
# For system clipboard access with Vim
# set-option -g default-command "reattach-to-user-namespace -l bash"
# Use y to copy to system buffer
# bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h
bind ^s split-window -v
bind ^v split-window -h
# 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
bind ^h select-pane -L
bind ^j select-pane -D
bind ^k select-pane -U
bind ^l select-pane -R
# 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 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10
# pane movement
bind-key i command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key t command-prompt -p "send pane to:" "join-pane -t '%%'"
# bind : to command-prompt like vim
# this is the default in tmux already
bind : command-prompt
# session management
bind C new-session
bind L choose-session
# vi-style controls for copy mode
setw -g mode-keys vi
# Set the prefix to ^A, like screen.
#
# NC: Or, rather, to ^O like my .screenrc.
unbind C-b
set -g prefix ^O
bind o send-prefix
bind ^o last-window # toggle last window like screen
set -g update-environment "DISPLAY WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
bind K confirm kill-server
bind X confirm kill-window
# longer scrollback
set -g history-limit 10000
set -g status-style bg=default,fg=white
# left side of status bar holds "(>- session name -<)"
set -g status-left-length 100
set -g status-left-style bg=green,fg=black,bold
set -g status-left ''
# right side of status bar holds "[host name] (date time)"
set -g status-right-length 100
set -g status-right-style fg=black,bold
set -g status-right '#[fg=colour214,bg=colour235] #H#[fg=colour238]:#[fg=colour178]#S #[fg=yellow,bg=colour238] %y.%m.%d %H:%M '
# make background window look like white tab
set-window-option -g window-status-style bg=default,fg=white,none
set-window-option -g window-status-format '#[fg=colour214,bg=colour235] #I #[fg=white,bg=colour236] #W #[default]'
# make foreground window look like bold yellow foreground tab
set-window-option -g window-status-current-style none
set-window-option -g window-status-current-format '#[fg=black,bg=colour214]#I#[fg=black,bg=yellow]#F#[fg=brightwhite,bg=colour238] #W #[default]'
# active terminal yellow border, non-active white
#
# NC: these options aren't defined in `man tmux` for my Tmux on Fedora
# 21, but they work in practice. Instead, I redefine them above using
# the syntax in the man page.
#
#set -g pane-border-bg default
#set -g pane-border-fg colour238
#set -g pane-active-border-bg default
#set -g pane-active-border-fg colour214
# set a 256color $TERM variable so programs inside tmux know they can use 256 colors
# NC: this screws up Emacs. For example, search highlighting blocks
# the matched part of the search!
#set -g default-terminal screen-256color
# reload tmux config file with C-a r
bind r source ~/.tmux.conf
# Create a new window and prompt for name
bind N command-prompt "new-window -n '%%'"
# Rebind prefix to b
bind B set -g prefix ^b
bind A set -g prefix ^a
# Run regular shells, not login shells, by default. This allows the
# env outside tmux to be inherited, and avoids login time path
# manipulations. If scripting tmux, this can be simulted in two steps:
#
# $ tmux -L <socket> new-session -d -s <session> -n <window> $SHELL
# $ tmux -L <socket> set-option -g default-command $SHELL
set-option -g default-command $SHELL
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
#
# NC: to install tpm you just clone its Git repo. Use <prefix>-I to
# install plugins defined with '@plugin' keyword above.
run '~/.tmux/plugins/tpm/tpm'