rmux-core 0.10.0

Core session, pane, layout, format, hook, and buffer model for the RMUX terminal multiplexer.
Documentation
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
use super::{key_code_lookup_bits, key_string_lookup_string, KeyCode};

const DEFAULT_LIST_KEYS_TMUX_3_4: &str = include_str!("default_list_keys_tmux_3_4.txt");

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct DefaultListKeysDisplay<'a> {
    pub(crate) index: usize,
    pub(crate) key_string: String,
    pub(crate) command_string: &'a str,
}

pub(crate) fn list_keys_displays(
    table_name: &str,
    key: KeyCode,
) -> Vec<DefaultListKeysDisplay<'static>> {
    DEFAULT_LIST_KEYS_TMUX_3_4
        .lines()
        .enumerate()
        .filter_map(|(index, line)| parse_default_list_keys_line(index, line))
        .filter(|row| {
            row.table_name == table_name
                && default_display_key_matches(row.key_string, key_code_lookup_bits(key))
        })
        .map(|row| DefaultListKeysDisplay {
            index: row.index,
            key_string: normalize_default_display_key(row.key_string).into_owned(),
            command_string: row.command_string,
        })
        .collect()
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct DefaultListKeysRow<'a> {
    index: usize,
    table_name: &'a str,
    key_string: &'a str,
    command_string: &'a str,
}

fn parse_default_list_keys_line(index: usize, line: &str) -> Option<DefaultListKeysRow<'_>> {
    let after_table_flag = line.split_once(" -T ")?.1.trim_start();
    let table_end = after_table_flag.find(char::is_whitespace)?;
    let table_name = &after_table_flag[..table_end];
    let after_table = after_table_flag[table_end..].trim_start();
    let key_end = after_table.find(char::is_whitespace)?;
    let key_string = &after_table[..key_end];
    let command_string = after_table[key_end..].trim_start();
    Some(DefaultListKeysRow {
        index,
        table_name,
        key_string,
        command_string,
    })
}

fn default_display_key_matches(display_key: &str, key: KeyCode) -> bool {
    let normalized = normalize_default_display_key(display_key);
    key_string_lookup_string(normalized.as_ref())
        .map(key_code_lookup_bits)
        .is_some_and(|candidate| candidate == key)
}

fn normalize_default_display_key(display_key: &str) -> std::borrow::Cow<'_, str> {
    if let Some(stripped) = display_key.strip_prefix('\\') {
        return std::borrow::Cow::Owned(stripped.to_owned());
    }
    if let Some(stripped) = display_key
        .strip_prefix('"')
        .and_then(|value| value.strip_suffix('"'))
    {
        return std::borrow::Cow::Owned(stripped.to_owned());
    }
    std::borrow::Cow::Borrowed(display_key)
}

pub(crate) const DEFAULT_BINDING_STRINGS: &[&str] = &[
    "bind -N 'Send the prefix key' C-b { send-prefix }",
    "bind -N 'Rotate through the panes' C-o { rotate-window }",
    "bind -N 'Suspend the current client' C-z { suspend-client }",
    "bind -N 'Select next layout' Space { next-layout }",
    "bind -N 'Break pane to a new window' ! { break-pane }",
    "bind -N 'Split window vertically' '\"' { split-window }",
    "bind -N 'List all paste buffers' '#' { list-buffers }",
    "bind -N 'Rename current session' '$' { command-prompt -I'#S' { rename-session -- '%%' } }",
    "bind -N 'Split window horizontally' % { split-window -h }",
    "bind -N 'Kill current window' & { confirm-before -p\"kill-window #W? (y/n)\" kill-window }",
    "bind -N 'Prompt for window index to select' \"'\" { command-prompt -T window-target -pindex { select-window -t ':%%' } }",
    "bind -N 'Switch to previous client' ( { switch-client -p }",
    "bind -N 'Switch to next client' ) { switch-client -n }",
    "bind -N 'Rename current window' , { command-prompt -I'#W' { rename-window -- '%%' } }",
    "bind -N 'Delete the most recent paste buffer' - { delete-buffer }",
    "bind -N 'Move the current window' . { command-prompt -T target { move-window -t '%%' } }",
    "bind -N 'Describe key binding' '/' { command-prompt -kpkey  { list-keys -1N '%%' } }",
    "bind -N 'Select window 0' 0 { select-window -t:=0 }",
    "bind -N 'Select window 1' 1 { select-window -t:=1 }",
    "bind -N 'Select window 2' 2 { select-window -t:=2 }",
    "bind -N 'Select window 3' 3 { select-window -t:=3 }",
    "bind -N 'Select window 4' 4 { select-window -t:=4 }",
    "bind -N 'Select window 5' 5 { select-window -t:=5 }",
    "bind -N 'Select window 6' 6 { select-window -t:=6 }",
    "bind -N 'Select window 7' 7 { select-window -t:=7 }",
    "bind -N 'Select window 8' 8 { select-window -t:=8 }",
    "bind -N 'Select window 9' 9 { select-window -t:=9 }",
    "bind -N 'Prompt for a command' : { command-prompt }",
    "bind -N 'Move to the previously active pane' \\; { last-pane }",
    "bind -N 'Choose a paste buffer from a list' = { choose-buffer -Z }",
    "bind -N 'List key bindings' ? { list-keys -N }",
    "bind -N 'Choose and detach a client from a list' D { choose-client -Z }",
    "bind -N 'Spread panes out evenly' E { select-layout -E }",
    "bind -N 'Switch to the last client' L { switch-client -l }",
    "bind -N 'Clear the marked pane' M { select-pane -M }",
    "bind -N 'Enter copy mode' [ { copy-mode }",
    "bind -N 'Paste the most recent paste buffer' ] { paste-buffer -p }",
    "bind -N 'Create a new window' c { new-window }",
    "bind -N 'Detach the current client' d { detach-client }",
    "bind -N 'Search for a pane' f { command-prompt { find-window -Z -- '%%' } }",
    "bind -N 'Display window information' i { display-message }",
    "bind -N 'Select the previously current window' l { last-window }",
    "bind -N 'Toggle the marked pane' m { select-pane -m }",
    "bind -N 'Select the next window' n { next-window }",
    "bind -N 'Select the next pane' o { select-pane -t:.+ }",
    "bind -N 'Customize options' C { customize-mode -Z }",
    "bind -N 'Select the previous window' p { previous-window }",
    "bind -N 'Display pane numbers' q { display-panes }",
    "bind -N 'Redraw the current client' r { refresh-client }",
    "bind -N 'Choose a session from a list' s { choose-tree -Zs }",
    "bind -N 'Show a clock' t { clock-mode }",
    "bind -N 'Choose a window from a list' w { choose-tree -Zw }",
    "bind -N 'Kill the active pane' x { confirm-before -p\"kill-pane #P? (y/n)\" kill-pane }",
    "bind -N 'Zoom the active pane' z { resize-pane -Z }",
    "bind -N 'Swap the active pane with the pane above' '{' { swap-pane -U }",
    "bind -N 'Swap the active pane with the pane below' '}' { swap-pane -D }",
    "bind -N 'Show messages' '~' { show-messages }",
    "bind -N 'Enter copy mode and scroll up' PPage { copy-mode -u }",
    "bind -N 'Select the pane above the active pane' -r Up { select-pane -U }",
    "bind -N 'Select the pane below the active pane' -r Down { select-pane -D }",
    "bind -N 'Select the pane to the left of the active pane' -r Left { select-pane -L }",
    "bind -N 'Select the pane to the right of the active pane' -r Right { select-pane -R }",
    "bind -N 'Set the even-horizontal layout' M-1 { select-layout even-horizontal }",
    "bind -N 'Set the even-vertical layout' M-2 { select-layout even-vertical }",
    "bind -N 'Set the main-horizontal layout' M-3 { select-layout main-horizontal }",
    "bind -N 'Set the main-vertical layout' M-4 { select-layout main-vertical }",
    "bind -N 'Select the tiled layout' M-5 { select-layout tiled }",
    "bind -N 'Set the main-horizontal-mirrored layout' M-6 { select-layout main-horizontal-mirrored }",
    "bind -N 'Set the main-vertical-mirrored layout' M-7 { select-layout main-vertical-mirrored }",
    "bind -N 'Select the next window with an alert' M-n { next-window -a }",
    "bind -N 'Rotate through the panes in reverse' M-o { rotate-window -D }",
    "bind -N 'Select the previous window with an alert' M-p { previous-window -a }",
    "bind -N 'Resize the pane up by 5' -r M-Up { resize-pane -U 5 }",
    "bind -N 'Resize the pane down by 5' -r M-Down { resize-pane -D 5 }",
    "bind -N 'Resize the pane left by 5' -r M-Left { resize-pane -L 5 }",
    "bind -N 'Resize the pane right by 5' -r M-Right { resize-pane -R 5 }",
    "bind -N 'Resize the pane up' -r C-Up { resize-pane -U }",
    "bind -N 'Resize the pane down' -r C-Down { resize-pane -D }",
    "bind -N 'Resize the pane left' -r C-Left { resize-pane -L }",
    "bind -N 'Resize the pane right' -r C-Right { resize-pane -R }",
    concat!(
        "bind -N 'Display window menu' < { display-menu -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' ",
        " '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}",
        " '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}",
        " ''",
        " 'Kill' 'X' {kill-window}",
        " 'Respawn' 'R' {respawn-window -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " 'Rename' 'n' {command-prompt -FI \"#W\" {rename-window -t '#{window_id}' -- '%%'}}",
        " ''",
        " 'New After' 'w' {new-window -a}",
        " 'New At End' 'W' {new-window}",
        " }"
    ),
    concat!(
        "bind -N 'Display pane menu' > { display-menu -xP -yP -T '#[align=centre]#{pane_index} (#{pane_id})' ",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}",
        " ''",
        " '#{?#{&&:#{buffer_size},#{!:#{pane_in_mode}}},Paste #[underscore]#{=/9/...:buffer_sample},}' 'p' {paste-buffer}",
        " ''",
        " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}",
        " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}",
        " ''",
        " '#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}' 'C-h' {copy-mode -q; send-keys -l -- \"#{q:mouse_hyperlink}\"}",
        " '#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}' 'h' {copy-mode -q; set-buffer -- \"#{q:mouse_hyperlink}\"}",
        " ''",
        " 'Horizontal Split' 'h' {split-window -h}",
        " 'Vertical Split' 'v' {split-window -v}",
        " ''",
        " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}",
        " '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}",
        " ''",
        " 'Kill' 'X' {kill-pane}",
        " 'Respawn' 'R' {respawn-pane -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}",
        " }"
    ),
    "bind -n MouseDown1Pane { select-pane -t=; send -M }",
    "bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }",
    "bind -n WheelUpPane { if -F '#{||:#{alternate_on},#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -e } }",
    "bind -n MouseDown2Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { paste -p } }",
    "bind -n DoubleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -Ht=; send -Xt= select-word; run -d0.3; send -Xt= copy-pipe-and-cancel } }",
    "bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -Ht=; send -Xt= select-line; run -d0.3; send -Xt= copy-pipe-and-cancel } }",
    "bind -n MouseDown1Border { select-pane -M }",
    "bind -n MouseDrag1Border { resize-pane -M }",
    "bind -n MouseDown1Status { switch-client -t= }",
    "bind -n MouseDown1ScrollbarUp { if -F -t= '#{pane_in_mode}' { send -X page-up } { copy-mode -u } }",
    "bind -n MouseDown1ScrollbarDown { if -F -t= '#{pane_in_mode}' { send -X page-down } { copy-mode -d } }",
    "bind -n MouseDrag1ScrollbarSlider { if -F -t= '#{pane_in_mode}' { send -X scroll-to-mouse } { copy-mode -S } }",
    "bind -n MouseDown1Control8 { resize-pane -Z }",
    "bind -n MouseDown1Control9 { display-menu -O -T 'Kill pane #{pane_index}?' -t= -xM -yM Yes y { kill-pane -t= } No n {  } }",
    "bind -n C-MouseDown1Pane { swap-pane -s @ }",
    "bind -n C-MouseDown1Status { swap-window -t @ }",
    "bind -n WheelDownStatus { next-window }",
    "bind -n WheelUpStatus { previous-window }",
    concat!(
        "bind -n MouseDown3StatusLeft { display-menu -t= -xM -yW -T '#[align=centre]#{session_name}' ",
        " 'Next' 'n' {switch-client -n}",
        " 'Previous' 'p' {switch-client -p}",
        " ''",
        " 'Renumber' 'N' {move-window -r}",
        " 'Rename' 'r' {command-prompt -I \"#S\" {rename-session -- '%%'}}",
        " 'Detach' 'd' {detach-client}",
        " ''",
        " 'New Session' 's' {new-session}",
        " 'New Window' 'w' {new-window}",
        " }"
    ),
    concat!(
        "bind -n M-MouseDown3StatusLeft { display-menu -t= -xM -yW -T '#[align=centre]#{session_name}' ",
        " 'Next' 'n' {switch-client -n}",
        " 'Previous' 'p' {switch-client -p}",
        " ''",
        " 'Renumber' 'N' {move-window -r}",
        " 'Rename' 'r' {command-prompt -I \"#S\" {rename-session -- '%%'}}",
        " 'Detach' 'd' {detach-client}",
        " ''",
        " 'New Session' 's' {new-session}",
        " 'New Window' 'w' {new-window}",
        " }"
    ),
    concat!(
        "bind -n MouseDown3Status { display-menu -t= -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' ",
        " '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}",
        " '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}",
        " ''",
        " 'Kill' 'X' {kill-window}",
        " 'Respawn' 'R' {respawn-window -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " 'Rename' 'n' {command-prompt -FI \"#W\" {rename-window -t '#{window_id}' -- '%%'}}",
        " ''",
        " 'New After' 'w' {new-window -a}",
        " 'New At End' 'W' {new-window}",
        "}"
    ),
    concat!(
        "bind -n M-MouseDown3Status { display-menu -t= -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' ",
        " '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}",
        " '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}",
        " ''",
        " 'Kill' 'X' {kill-window}",
        " 'Respawn' 'R' {respawn-window -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " 'Rename' 'n' {command-prompt -FI \"#W\" {rename-window -t '#{window_id}' -- '%%'}}",
        " ''",
        " 'New After' 'w' {new-window -a}",
        " 'New At End' 'W' {new-window}",
        "}"
    ),
    concat!(
        "bind -n MouseDown3Pane { if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' ",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}",
        " ''",
        " '#{?#{&&:#{buffer_size},#{!:#{pane_in_mode}}},Paste #[underscore]#{=/9/...:buffer_sample},}' 'p' {paste-buffer}",
        " ''",
        " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}",
        " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}",
        " ''",
        " '#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}' 'C-h' {copy-mode -q; send-keys -l -- \"#{q:mouse_hyperlink}\"}",
        " '#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}' 'h' {copy-mode -q; set-buffer -- \"#{q:mouse_hyperlink}\"}",
        " ''",
        " 'Horizontal Split' 'h' {split-window -h}",
        " 'Vertical Split' 'v' {split-window -v}",
        " ''",
        " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}",
        " '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}",
        " ''",
        " 'Kill' 'X' {kill-pane}",
        " 'Respawn' 'R' {respawn-pane -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}",
        " } }"
    ),
    concat!(
        "bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' ",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}",
        " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}",
        " ''",
        " '#{?#{&&:#{buffer_size},#{!:#{pane_in_mode}}},Paste #[underscore]#{=/9/...:buffer_sample},}' 'p' {paste-buffer}",
        " ''",
        " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}",
        " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}",
        " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}",
        " ''",
        " '#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}' 'C-h' {copy-mode -q; send-keys -l -- \"#{q:mouse_hyperlink}\"}",
        " '#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}' 'h' {copy-mode -q; set-buffer -- \"#{q:mouse_hyperlink}\"}",
        " ''",
        " 'Horizontal Split' 'h' {split-window -h}",
        " 'Vertical Split' 'v' {split-window -v}",
        " ''",
        " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}",
        " '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}",
        " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}",
        " ''",
        " 'Kill' 'X' {kill-pane}",
        " 'Respawn' 'R' {respawn-pane -k}",
        " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}",
        " '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}",
        " }"
    ),
    "bind -Tcopy-mode C-Space { send -X begin-selection }",
    "bind -Tcopy-mode C-a { send -X start-of-line }",
    "bind -Tcopy-mode C-c { send -X cancel }",
    "bind -Tcopy-mode C-e { send -X end-of-line }",
    "bind -Tcopy-mode C-f { send -X cursor-right }",
    "bind -Tcopy-mode C-b { send -X cursor-left }",
    "bind -Tcopy-mode C-g { send -X clear-selection }",
    "bind -Tcopy-mode C-k { send -X copy-pipe-end-of-line-and-cancel }",
    "bind -Tcopy-mode C-l { send -X recentre-top-bottom }",
    "bind -Tcopy-mode C-n { send -X cursor-down }",
    "bind -Tcopy-mode C-p { send -X cursor-up }",
    "bind -Tcopy-mode C-r { command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' { send -X search-backward-incremental -- '%%' } }",
    "bind -Tcopy-mode C-s { command-prompt -T search -ip'(search down)' -I'#{pane_search_string}' { send -X search-forward-incremental -- '%%' } }",
    "bind -Tcopy-mode C-v { send -X page-down }",
    "bind -Tcopy-mode C-w { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode Escape { send -X cancel }",
    "bind -Tcopy-mode C-[ { send -X cancel }",
    "bind -Tcopy-mode Space { send -X page-down }",
    "bind -Tcopy-mode , { send -X jump-reverse }",
    "bind -Tcopy-mode \\; { send -X jump-again }",
    "bind -Tcopy-mode F { command-prompt -1p'(jump backward)' { send -X jump-backward -- '%%' } }",
    "bind -Tcopy-mode N { send -X search-reverse }",
    "bind -Tcopy-mode P { send -X toggle-position }",
    "bind -Tcopy-mode R { send -X rectangle-toggle }",
    "bind -Tcopy-mode T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward -- '%%' } }",
    "bind -Tcopy-mode X { send -X set-mark }",
    "bind -Tcopy-mode f { command-prompt -1p'(jump forward)' { send -X jump-forward -- '%%' } }",
    "bind -Tcopy-mode g { command-prompt -p'(goto line)' { send -X goto-line -- '%%' } }",
    "bind -Tcopy-mode n { send -X search-again }",
    "bind -Tcopy-mode q { send -X cancel }",
    "bind -Tcopy-mode r { send -X refresh-from-pane }",
    "bind -Tcopy-mode t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward -- '%%' } }",
    "bind -Tcopy-mode Home { send -X start-of-line }",
    "bind -Tcopy-mode End { send -X end-of-line }",
    "bind -Tcopy-mode MouseDown1Pane select-pane",
    "bind -Tcopy-mode MouseDrag1Pane { select-pane; send -X begin-selection }",
    "bind -Tcopy-mode MouseDragEnd1Pane { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode WheelUpPane { select-pane; send -N5 -X scroll-up }",
    "bind -Tcopy-mode WheelDownPane { select-pane; send -N5 -X scroll-down }",
    "bind -Tcopy-mode DoubleClick1Pane { select-pane -t=; send -Xt= select-word; run -d0.3; send -Xt= copy-pipe-and-cancel }",
    "bind -Tcopy-mode TripleClick1Pane { select-pane -t=; send -Xt= select-line; run -d0.3; send -Xt= copy-pipe-and-cancel }",
    "bind -Tcopy-mode NPage { send -X page-down }",
    "bind -Tcopy-mode PPage { send -X page-up }",
    "bind -Tcopy-mode Up { send -X cursor-up }",
    "bind -Tcopy-mode Down { send -X cursor-down }",
    "bind -Tcopy-mode Left { send -X cursor-left }",
    "bind -Tcopy-mode Right { send -X cursor-right }",
    "bind -Tcopy-mode M-1 { command-prompt -Np'(repeat)' -I1 { send -N '%%' } }",
    "bind -Tcopy-mode M-2 { command-prompt -Np'(repeat)' -I2 { send -N '%%' } }",
    "bind -Tcopy-mode M-3 { command-prompt -Np'(repeat)' -I3 { send -N '%%' } }",
    "bind -Tcopy-mode M-4 { command-prompt -Np'(repeat)' -I4 { send -N '%%' } }",
    "bind -Tcopy-mode M-5 { command-prompt -Np'(repeat)' -I5 { send -N '%%' } }",
    "bind -Tcopy-mode M-6 { command-prompt -Np'(repeat)' -I6 { send -N '%%' } }",
    "bind -Tcopy-mode M-7 { command-prompt -Np'(repeat)' -I7 { send -N '%%' } }",
    "bind -Tcopy-mode M-8 { command-prompt -Np'(repeat)' -I8 { send -N '%%' } }",
    "bind -Tcopy-mode M-9 { command-prompt -Np'(repeat)' -I9 { send -N '%%' } }",
    "bind -Tcopy-mode M-< { send -X history-top }",
    "bind -Tcopy-mode M-> { send -X history-bottom }",
    "bind -Tcopy-mode M-R { send -X top-line }",
    "bind -Tcopy-mode M-b { send -X previous-word }",
    "bind -Tcopy-mode C-M-b { send -X previous-matching-bracket }",
    "bind -Tcopy-mode M-f { send -X next-word-end }",
    "bind -Tcopy-mode M-l { send -X cursor-centre-horizontal }",
    "bind -Tcopy-mode C-M-f { send -X next-matching-bracket }",
    "bind -Tcopy-mode M-m { send -X back-to-indentation }",
    "bind -Tcopy-mode M-r { send -X middle-line }",
    "bind -Tcopy-mode M-v { send -X page-up }",
    "bind -Tcopy-mode M-w { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode M-x { send -X jump-to-mark }",
    "bind -Tcopy-mode 'M-{' { send -X previous-paragraph }",
    "bind -Tcopy-mode 'M-}' { send -X next-paragraph }",
    "bind -Tcopy-mode M-Up { send -X halfpage-up }",
    "bind -Tcopy-mode M-Down { send -X halfpage-down }",
    "bind -Tcopy-mode C-Up { send -X scroll-up }",
    "bind -Tcopy-mode C-Down { send -X scroll-down }",
    "bind -Tcopy-mode-vi '#' { send -FX search-backward -- '#{copy_cursor_word}' }",
    "bind -Tcopy-mode-vi * { send -FX search-forward -- '#{copy_cursor_word}' }",
    "bind -Tcopy-mode-vi C-c { send -X cancel }",
    "bind -Tcopy-mode-vi C-d { send -X halfpage-down }",
    "bind -Tcopy-mode-vi C-e { send -X scroll-down }",
    "bind -Tcopy-mode-vi C-b { send -X page-up }",
    "bind -Tcopy-mode-vi C-f { send -X page-down }",
    "bind -Tcopy-mode-vi C-h { send -X cursor-left }",
    "bind -Tcopy-mode-vi C-j { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode-vi Enter { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode-vi C-u { send -X halfpage-up }",
    "bind -Tcopy-mode-vi C-v { send -X rectangle-toggle }",
    "bind -Tcopy-mode-vi C-y { send -X scroll-up }",
    "bind -Tcopy-mode-vi Escape { send -X clear-selection }",
    "bind -Tcopy-mode-vi C-[ { send -X clear-selection }",
    "bind -Tcopy-mode-vi Space { send -X begin-selection }",
    "bind -Tcopy-mode-vi '$' { send -X end-of-line }",
    "bind -Tcopy-mode-vi , { send -X jump-reverse }",
    "bind -Tcopy-mode-vi / { command-prompt -T search -p'(search down)' { send -X search-forward -- '%%' } }",
    "bind -Tcopy-mode-vi 0 { send -X start-of-line }",
    "bind -Tcopy-mode-vi 1 { command-prompt -Np'(repeat)' -I1 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 2 { command-prompt -Np'(repeat)' -I2 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 3 { command-prompt -Np'(repeat)' -I3 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 4 { command-prompt -Np'(repeat)' -I4 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 5 { command-prompt -Np'(repeat)' -I5 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 6 { command-prompt -Np'(repeat)' -I6 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 7 { command-prompt -Np'(repeat)' -I7 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 8 { command-prompt -Np'(repeat)' -I8 { send -N '%%' } }",
    "bind -Tcopy-mode-vi 9 { command-prompt -Np'(repeat)' -I9 { send -N '%%' } }",
    "bind -Tcopy-mode-vi : { command-prompt -p'(goto line)' { send -X goto-line -- '%%' } }",
    "bind -Tcopy-mode-vi \\; { send -X jump-again }",
    "bind -Tcopy-mode-vi ? { command-prompt -T search -p'(search up)' { send -X search-backward -- '%%' } }",
    "bind -Tcopy-mode-vi A { send -X append-selection-and-cancel }",
    "bind -Tcopy-mode-vi B { send -X previous-space }",
    "bind -Tcopy-mode-vi D { send -X copy-pipe-end-of-line-and-cancel }",
    "bind -Tcopy-mode-vi E { send -X next-space-end }",
    "bind -Tcopy-mode-vi F { command-prompt -1p'(jump backward)' { send -X jump-backward -- '%%' } }",
    "bind -Tcopy-mode-vi G { send -X history-bottom }",
    "bind -Tcopy-mode-vi H { send -X top-line }",
    "bind -Tcopy-mode-vi J { send -X scroll-down }",
    "bind -Tcopy-mode-vi K { send -X scroll-up }",
    "bind -Tcopy-mode-vi L { send -X bottom-line }",
    "bind -Tcopy-mode-vi M { send -X middle-line }",
    "bind -Tcopy-mode-vi N { send -X search-reverse }",
    "bind -Tcopy-mode-vi P { send -X toggle-position }",
    "bind -Tcopy-mode-vi T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward -- '%%' } }",
    "bind -Tcopy-mode-vi V { send -X select-line }",
    "bind -Tcopy-mode-vi W { send -X next-space }",
    "bind -Tcopy-mode-vi X { send -X set-mark }",
    "bind -Tcopy-mode-vi ^ { send -X back-to-indentation }",
    "bind -Tcopy-mode-vi b { send -X previous-word }",
    "bind -Tcopy-mode-vi e { send -X next-word-end }",
    "bind -Tcopy-mode-vi f { command-prompt -1p'(jump forward)' { send -X jump-forward -- '%%' } }",
    "bind -Tcopy-mode-vi g { send -X history-top }",
    "bind -Tcopy-mode-vi h { send -X cursor-left }",
    "bind -Tcopy-mode-vi j { send -X cursor-down }",
    "bind -Tcopy-mode-vi k { send -X cursor-up }",
    "bind -Tcopy-mode-vi z { send -X scroll-middle }",
    "bind -Tcopy-mode-vi l { send -X cursor-right }",
    "bind -Tcopy-mode-vi n { send -X search-again }",
    "bind -Tcopy-mode-vi o { send -X other-end }",
    "bind -Tcopy-mode-vi q { send -X cancel }",
    "bind -Tcopy-mode-vi r { send -X refresh-from-pane }",
    "bind -Tcopy-mode-vi t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward -- '%%' } }",
    "bind -Tcopy-mode-vi v { send -X rectangle-toggle }",
    "bind -Tcopy-mode-vi w { send -X next-word }",
    "bind -Tcopy-mode-vi '{' { send -X previous-paragraph }",
    "bind -Tcopy-mode-vi '}' { send -X next-paragraph }",
    "bind -Tcopy-mode-vi % { send -X next-matching-bracket }",
    "bind -Tcopy-mode-vi Home { send -X start-of-line }",
    "bind -Tcopy-mode-vi End { send -X end-of-line }",
    "bind -Tcopy-mode-vi MouseDown1Pane { select-pane }",
    "bind -Tcopy-mode-vi MouseDrag1Pane { select-pane; send -X begin-selection }",
    "bind -Tcopy-mode-vi MouseDragEnd1Pane { send -X copy-pipe-and-cancel }",
    "bind -Tcopy-mode-vi WheelUpPane { select-pane; send -N5 -X scroll-up }",
    "bind -Tcopy-mode-vi WheelDownPane { select-pane; send -N5 -X scroll-down }",
    "bind -Tcopy-mode-vi DoubleClick1Pane { select-pane -t=; send -Xt= select-word; run -d0.3; send -Xt= copy-pipe-and-cancel }",
    "bind -Tcopy-mode-vi TripleClick1Pane { select-pane -t=; send -Xt= select-line; run -d0.3; send -Xt= copy-pipe-and-cancel }",
    "bind -Tcopy-mode-vi BSpace { send -X cursor-left }",
    "bind -Tcopy-mode-vi NPage { send -X page-down }",
    "bind -Tcopy-mode-vi PPage { send -X page-up }",
    "bind -Tcopy-mode-vi Up { send -X cursor-up }",
    "bind -Tcopy-mode-vi Down { send -X cursor-down }",
    "bind -Tcopy-mode-vi Left { send -X cursor-left }",
    "bind -Tcopy-mode-vi Right { send -X cursor-right }",
    "bind -Tcopy-mode-vi M-x { send -X jump-to-mark }",
    "bind -Tcopy-mode-vi C-Up { send -X scroll-up }",
    "bind -Tcopy-mode-vi C-Down { send -X scroll-down }",
];