-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathzellij.ts
1045 lines (1036 loc) · 25.5 KB
/
zellij.ts
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const generateSessions: Fig.Generator = {
script: {
command: "zellij",
args: ["list-sessions", "-n"],
},
postProcess: (out) => {
if (out.includes("No active zellij sessions found")) {
return [];
}
return out
.split("\n")
.filter(Boolean)
.map((line) => {
const name = line.split("[")[0].trim();
const createdMatch = line.match(/\[Created (.+?) ago\]/);
const isExited = line.includes("EXITED");
let description = "";
if (createdMatch) {
description = `Created ${createdMatch[1]} ago`;
}
if (isExited) {
description += " (EXITED)";
}
return {
name: name,
description: description,
icon: isExited ? "⚠️" : "📟",
priority: isExited ? 51 : 75,
};
});
},
};
const option: Fig.Option[] = [
{
name: ["-c", "--config"],
description: "Change where zellij looks for the configuration file",
args: {
name: "CONFIG",
generators: {
template: "filepaths",
},
},
},
{
name: "--config-dir",
description: "Change where zellij looks for the configuration directory",
args: {
name: "CONFIG_DIR",
generators: {
template: "folders",
},
},
},
{
name: ["-d", "--debug"],
description: "Specify emitting additional debug information",
},
{
name: "--data-dir",
description: "Change where zellij looks for plugins",
args: {
name: "DATA_DIR",
generators: {
template: "folders",
},
},
},
{
name: ["-h", "--help"],
description: "Print help information",
isPersistent: true,
},
{
name: ["-l", "--layout"],
description:
"Name of a predefined layout inside the layout directory or the path to a layout file",
args: {
name: "LAYOUT",
generators: {
template: "filepaths",
},
},
},
{
name: "--max-panes",
description:
"Maximum panes on screen, caution: opening more panes will close old ones",
args: {
name: "MAX_PANES",
},
},
{
name: ["-n", "--new-session-with-layout"],
description:
"Name of a predefined layout inside the layout directory or the path to a layout file",
args: {
name: "NEW_SESSION_WITH_LAYOUT",
generators: {
template: "filepaths",
},
},
},
{
name: ["-s", "--session"],
description: "Specify name of a new session",
args: {
name: "SESSION",
},
},
{
name: ["-V", "--version"],
description: "Print version information",
},
];
const actionSubcommands: Fig.Subcommand[] = [
{
name: "clear",
description: "Clear all buffers for a focused pane",
},
{
name: "close-pane",
description: "Close the focused pane",
},
{
name: "close-tab",
description: "Close the current tab",
},
{
name: "dump-layout",
description: "Dump current layout to stdout",
},
{
name: "dump-screen",
description: "Dump the focused pane to a file",
args: {
name: "FILE",
generators: {
template: "filepaths",
},
},
},
{
name: "edit",
description:
"Open the specified file in a new zellij pane with your default EDITOR",
},
{
name: "edit-scrollback",
description: "Open the pane scrollback in your default editor",
},
{
name: "focus-next-pane",
description: "Change focus to the next pane",
},
{
name: "focus-previous-pane",
description: "Change focus to the previous pane",
},
{
name: "go-to-next-tab",
description: "Go to the next tab",
},
{
name: "go-to-previous-tab",
description: "Go to the previous tab",
},
{
name: "go-to-tab",
description: "Go to tab with index [index]",
},
{
name: "go-to-tab-name",
description: "Go to tab with name [name]",
},
{
name: "half-page-scroll-down",
description: "Scroll down half page in focus pane",
},
{
name: "half-page-scroll-up",
description: "Scroll up half page in focus pane",
},
{
name: "help",
description: "Print this message or the help of the given subcommand(s)",
},
{
name: "launch-or-focus-plugin",
description: "Launch or focus a plugin",
},
{
name: "launch-plugin",
description: "Launch a plugin",
},
{
name: "list-clients",
description: "List connected clients",
},
{
name: "move-focus",
description:
"Move the focused pane in the specified direction. [right|left|up|down]",
},
{
name: "move-focus-or-tab",
description:
"Move focus to the pane or tab (if on screen edge) in the specified direction [right|left|up|down]",
},
{
name: "move-pane",
description:
"Change the location of the focused pane in the specified direction or rotate forwards [right|left|up|down]",
},
{
name: "move-pane-backwards",
description: "Rotate the location of the previous pane backwards",
},
{
name: "move-tab",
description:
"Move the focused tab in the specified direction. [right|left]",
},
{
name: "new-pane",
description:
"Open a new pane in the specified direction [right|down] If no direction is specified, will try to use the biggest available space",
},
{
name: "new-tab",
description:
"Create a new tab, optionally with a specified tab layout and name",
},
{
name: "next-swap-layout",
description: "Swap to the next layout",
},
{
name: "page-scroll-down",
description: "Scroll down one page in focus pane",
},
{
name: "page-scroll-up",
description: "Scroll up one page in focus pane",
},
{
name: "previous-swap-layout",
description: "Swap to the previous layout",
},
{
name: "query-tab-names",
description: "Query all tab names",
},
{
name: "rename-pane",
description: "Renames the focused pane",
},
{
name: "rename-session",
description: "Rename the current session",
},
{
name: "rename-tab",
description: "Renames the focused pane",
},
{
name: "resize",
description:
"[increase|decrease] the focused panes area at the [left|down|up|right] border",
},
{
name: "scroll-down",
description: "Scroll down in focus pane",
},
{
name: "scroll-to-bottom",
description: "Scroll down to bottom in focus pane",
},
{
name: "scroll-to-top",
description: "Scroll up to top in focus pane",
},
{
name: "scroll-up",
description: "Scroll up in the focused pane",
},
{
name: "start-or-reload-plugin",
description: "Start or reload a plugin",
},
{
name: "switch-mode",
description:
"Switch input mode of all connected clients [locked|pane|tab|resize|move|search|session]",
},
{
name: "toggle-active-sync-tab",
description:
"Toggle between sending text commands to all panes on the current tab and normal mode",
},
{
name: "toggle-floating-panes",
description:
"Toggle the visibility of all floating panes in the current Tab, open one if none exist",
},
{
name: "toggle-fullscreen",
description: "Toggle between fullscreen focus pane and normal layout",
},
{
name: "toggle-pane-embed-or-floating",
description:
"Embed focused pane if floating or float focused pane if embedded",
},
{
name: "toggle-pane-frames",
description: "Toggle frames around panes in the UI",
},
{
name: "undo-rename-pane",
description: "Remove a previously set pane name",
},
{
name: "undo-rename-tab",
description: "Remove a previously set tab name",
},
{
name: "write",
description: "Write bytes to the terminal",
},
{
name: "write-chars",
description: "Write characters to the terminal",
},
];
const subcommands: Fig.Subcommand[] = [
{
name: ["action", "ac"],
description: "Send actions to a specific session",
subcommands: actionSubcommands,
},
{
name: ["attach", "a"],
description: "Attach to a session",
options: [
{
name: ["-b", "--background"],
description:
"Create a detached session in the background if one does not exist",
},
{
name: ["-c", "--create"],
description: "Create a session if one does not exist",
},
{
name: ["-f", "--force-run-commands"],
description:
"If resurrecting a dead session, immediately run all its commands on startup",
},
{
name: "--index",
description:
"Number of the session index in the active sessions ordered creation date",
},
],
args: {
name: "SESSION_NAME",
description: "Name of the session to attach to",
generators: generateSessions,
},
},
{
name: "convert-config",
description: "Convert configuration files",
args: {
name: "CONFIG",
generators: {
template: "filepaths",
},
},
},
{
name: "convert-layout",
description: "Convert layout files",
args: {
name: "LAYOUT",
generators: {
template: "filepaths",
},
},
},
{
name: "convert-theme",
description: "Convert theme files",
args: {
name: "THEME",
generators: {
template: "filepaths",
},
},
},
{
name: ["delete-all-sessions", "da"],
description: "Delete all sessions",
options: [
{
name: ["-f", "--force"],
description:
"Kill the sessions if they're running before deleting them",
},
{
name: ["-y", "--yes"],
description: "Automatic yes to prompts",
},
],
},
{
name: ["delete-session", "d"],
description: "Delete a specific session",
options: [
{
name: ["-f", "--force"],
description:
"Kill the sessions if they're running before deleting them",
},
],
args: {
name: "TARGET_SESSION",
description: "Name of the session to delete",
generators: generateSessions,
},
},
{
name: ["edit", "e"],
description: "Edit file with default $EDITOR / $VISUAL",
args: {
name: "FILE",
generators: {
template: "filepaths",
},
},
options: [
{
name: "--cwd",
description: "Change the working directory of the editor",
args: {
name: "CWD",
generators: {
template: "folders",
},
},
},
{
name: ["-d", "--direction"],
description: "Direction to open the new pane in",
args: {
name: "DIRECTION",
},
},
{
name: ["-f", "--floating"],
description: "Open the new pane in floating mode",
},
{
name: "--height",
description:
"The height if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "HEIGHT",
},
},
{
name: ["-i", "--in-place"],
description:
"Open the new pane in place of the current pane, temporarily suspending it",
},
{
name: ["-l", "--line-number"],
description: "Open the file in the specified line number",
args: {
name: "LINE_NUMBER",
},
},
{
name: "--width",
description:
"The width if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "WIDTH",
},
},
{
name: ["-x", "--x"],
description:
"The x coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "X",
},
},
{
name: ["-y", "--y"],
description:
"The y coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "Y",
},
},
],
},
{
name: "help",
description: "Print this message or the help of the given subcommand(s)",
},
{
name: ["kill-all-sessions", "ka"],
description: "Kill all sessions",
options: [
{
name: ["-y", "--yes"],
description: "Automatic yes to prompts",
},
],
},
{
name: ["kill-session", "k"],
description: "Kill a specific session",
args: {
name: "TARGET_SESSION",
description: "Name of the session to kill",
generators: generateSessions,
},
},
{
name: ["list-aliases", "la"],
description: "List existing plugin aliases",
},
{
name: ["list-sessions", "ls"],
description: "List active sessions",
options: [
{
name: ["-n", "--no-formatting"],
description: "Do not add colors and formatting to the list",
},
{
name: ["-r", "--reverse"],
description: "List the sessions in reverse order",
},
{
name: ["-s", "--short"],
description: "Print just the session name",
},
],
},
{
name: "options",
description: "Change the behaviour of zellij",
options: [
{
name: "--attach-to-session",
description:
"Whether to attach to a session specified in 'session-name' if it exists",
args: {
name: "ATTACH_TO_SESSION",
suggestions: ["true", "false"],
},
},
{
name: "--auto-layout",
description:
"Whether to lay out panes in a predefined set of layouts whenever possible",
args: {
name: "AUTO_LAYOUT",
suggestions: ["true", "false"],
},
},
{
name: "--copy-clipboard",
description: "OSC52 destination clipboard",
args: {
name: "COPY_CLIPBOARD",
suggestions: ["system", "primary"],
},
},
{
name: "--copy-command",
description:
"Switch to using a user supplied command for clipboard instead of OSC52",
args: {
name: "COPY_COMMAND",
},
},
{
name: "--copy-on-select",
description: "Automatically copy when selecting text (true or false)",
args: {
name: "COPY_ON_SELECT",
suggestions: ["true", "false"],
},
},
{
name: "--default-cwd",
description: "Set the default cwd",
args: {
name: "DEFAULT_CWD",
},
},
{
name: "--default-layout",
description: "Set the default layout",
args: {
name: "DEFAULT_LAYOUT",
},
},
{
name: "--default-mode",
description: "Set the default mode",
args: {
name: "DEFAULT_MODE",
},
},
{
name: "--default-shell",
description: "Set the default shell",
args: {
name: "DEFAULT_SHELL",
},
},
{
name: "--disable-mouse-mode",
description: "Disable handling of mouse events",
},
{
name: "--disable-session-metadata",
description: "If true, will disable writing session metadata to disk",
args: {
name: "DISABLE_SESSION_METADATA",
suggestions: ["true", "false"],
},
},
{
name: "--layout-dir",
description:
"Set the layout_dir, defaults to subdirectory of config dir",
args: {
name: "LAYOUT_DIR",
generators: {
template: "folders",
},
},
},
{
name: "--mirror-session",
description: "Mirror session when multiple users are connected",
args: {
name: "MIRROR_SESSION",
suggestions: ["true", "false"],
},
},
{
name: "--mouse-mode",
description:
"Set the handling of mouse events (true or false) Can be temporarily bypassed by the [SHIFT] key",
args: {
name: "MOUSE_MODE",
suggestions: ["true", "false"],
},
},
{
name: "--no-pane-frames",
description: "Disable display of pane frames",
},
{
name: "--on-force-close",
description: "Set behaviour on force close (quit or detach)",
args: {
name: "ON_FORCE_CLOSE",
},
},
{
name: "--pane-frames",
description: "Set display of the pane frames (true or false)",
args: {
name: "PANE_FRAMES",
suggestions: ["true", "false"],
},
},
{
name: "--scroll-buffer-size",
description: "",
args: {
name: "SCROLL_BUFFER_SIZE",
},
},
{
name: "--scrollback-editor",
description:
"Explicit full path to open the scrollback editor (default is $EDITOR or $VISUAL)",
args: {
name: "SCROLLBACK_EDITOR",
},
},
{
name: "--scrollback-lines-to-serialize",
description:
"Scrollback lines to serialize along with the pane viewport when serializing sessions, 0 defaults to the scrollback size. If this number is higher than the scrollback size, it will also default to the scrollback size",
args: {
name: "SCROLLBACK_LINES_TO_SERIALIZE",
},
},
{
name: "--serialization-interval",
description:
"The interval at which to serialize sessions for resurrection (in seconds)",
args: {
name: "SERIALIZATION_INTERVAL",
},
},
{
name: "--serialize-pane-viewport",
description:
"Whether pane viewports are serialized along with the session, default is false",
args: {
name: "SERIALIZE_PANE_VIEWPORT",
suggestions: ["true", "false"],
},
},
{
name: "--session-name",
description: "The name of the session to create when starting Zellij",
args: {
name: "SESSION_NAME",
},
},
{
name: "--session-serialization",
description: "Whether sessions should be serialized to the HD",
args: {
name: "SESSION_SERIALIZATION",
suggestions: ["true", "false"],
},
},
{
name: "--simplified-ui",
description:
"Allow plugins to use a more simplified layout that is compatible with more fonts",
args: {
name: "SIMPLIFIED_UI",
suggestions: ["true", "false"],
},
},
{
name: "--styled-underlines",
description: "Whether to use ANSI styled underlines",
args: {
name: "STYLED_UNDERLINES",
suggestions: ["true", "false"],
},
},
{
name: "--support-kitty-keyboard-protocol",
description:
"Whether to enable support for the Kitty keyboard protocol",
args: {
name: "SUPPORT_KITTY_KEYBOARD_PROTOCOL",
suggestions: ["true", "false"],
},
},
{
name: "--theme",
description: "Set the default theme",
args: {
name: "THEME",
},
},
{
name: "--theme-dir",
description:
"Set the theme_dir, defaults to subdirectory of config dir",
args: {
name: "THEME_DIR",
generators: {
template: "folders",
},
},
},
],
},
{
name: "pipe",
description:
"Send data to one or more plugins, launch them if they are not running",
args: {
name: "PAYLOAD",
description: "The data to send down this pipe",
},
options: [
{
name: ["-n", "--name"],
description: "The name of the pipe",
args: {
name: "NAME",
},
},
{
name: ["-a", "--args"],
description: "The args of the pipe",
args: {
name: "ARGS",
},
},
{
name: ["-p", "--plugin"],
description:
"The plugin url (eg. file:/tmp/my-plugin.wasm) to direct this pipe to, if not specified, will be sent to all plugins, if specified and is not running, the plugin will be launched",
args: {
name: "PLUGIN",
},
},
{
name: ["-c", "--plugin-configuration"],
description:
"The plugin configuration (note: the same plugin with different configuration is considered a different plugin for the purposes of determining the pipe destination)",
args: {
name: "PLUGIN_CONFIGURATION",
},
},
],
},
{
name: ["plugin", "p"],
description: "Load a plugin",
args: {
name: "URL",
description:
"Plugin URL, can either start with http(s), file: or zellij:",
},
options: [
{
name: ["-c", "--configuration"],
description: "Plugin configuration",
args: {
name: "CONFIGURATION",
},
},
{
name: ["-f", "--floating"],
description: "Open the new pane in floating mode",
},
{
name: "--height",
description:
"The height if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "HEIGHT",
},
},
{
name: ["-i", "--in-place"],
description:
"Open the new pane in place of the current pane, temporarily suspending it",
},
{
name: "--width",
description:
"The width if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "WIDTH",
},
},
{
name: ["-x", "--x"],
description:
"The x coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "X",
},
},
{
name: ["-y", "--y"],
description:
"The y coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "Y",
},
},
],
},
{
name: ["run", "r"],
description: "Run a command in a new pane",
args: {
name: "COMMAND",
description: "Command to run",
},
options: [
{
name: ["-c", "--close-on-exit"],
description: "Close the pane immediately when its command exits",
},
{
name: "--cwd",
description: "Change the working directory of the new pane",
args: {
name: "CWD",
generators: {
template: "folders",
},
},
},
{
name: ["-d", "--direction"],
description: "Direction to open the new pane in",
args: {
name: "DIRECTION",
},
},
{
name: ["-f", "--floating"],
description: "Open the new pane in floating mode",
},
{
name: "--height",
description:
"The height if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "HEIGHT",
},
},
{
name: ["-i", "--in-place"],
description:
"Open the new pane in place of the current pane, temporarily suspending it",
},
{
name: ["-n", "--name"],
description: "Name of the new pane",
args: {
name: "NAME",
},
},
{
name: ["-s", "--start-suspended"],
description:
"Start the command suspended, only running after you first presses ENTER",
},
{
name: "--width",
description:
"The width if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "WIDTH",
},
},
{
name: ["-x", "--x"],
description:
"The x coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "X",
},
},
{
name: ["-y", "--y"],
description:
"The y coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%)",
args: {
name: "Y",
},
},
],
},
{
name: "setup",
description: "Setup zellij and check its configuration",
options: [
{
name: "--check",
description:
"Checks the configuration of zellij and displays currently used directories",
},
{
name: "--clean",
description:
"Disables loading of configuration file at default location, loads the defaults that zellij ships with",
},
{
name: "--dump-config",
description: "Dump the default configuration file to stdout",
},
{
name: "--dump-layout",
description: "Dump specified layout to stdout",
args: {