-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_videos.py
1981 lines (1844 loc) · 52.8 KB
/
generate_videos.py
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
#!/usr/bin/env python3
import asyncio
import os
import shutil
import subprocess
from pathlib import Path
# The absolute path to run the script from
WORKING_DIRECTORY = Path(__file__).parent
# The path to the VHS tapes directory
VHS_TAPES_DIRECTORY: str = "./vhs_tapes"
# The set of archive file extensions
ARCHIVE_FILE_EXTENSIONS: set[str] = {".zip", ".7z"}
# The plugin command template
PLUGIN_COMMAND_TEMPLATE = "plugin augment-command --args='{}'"
# The default key to use for a command
DEFAULT_KEY = "e"
# The settings for all demos
CONFIG: str = "\n".join(
[
"Set FontSize 20",
'Set FontFamily "CaskaydiaCove NFM"',
'Set Theme "BlulocoDark"',
"Set Padding 20",
"Set Margin 0",
]
)
# The normal typing speed for all demos
NORMAL_TYPING_SPEED: str = "Set TypingSpeed 150ms"
# The typing speed for set up and clean up
FAST_TYPING_SPEED: str = "Set TypingSpeed 0.1ms"
# A long sleep time for some actions
LONG_SLEEP_TIME: str = "Sleep 2s"
# A sleep time for most actions
SLEEP_TIME: str = "Sleep 1s"
# A shorter sleep time for some actions
SHORT_SLEEP_TIME: str = "Sleep 500ms"
# A very short sleep time for some actions
VERY_SHORT_SLEEP_TIME: str = "Sleep 250ms"
# The command to change the working directory for all VHS tapes
CHANGE_TO_WORKING_DIRECTORY: str = f'Type "cd {WORKING_DIRECTORY}" Enter'
# The command to clear the screen
CLEAR_SCREEN: str = "Type 'clear' Enter"
class Script:
"A class to represent a script for a VHS tape"
__slots__ = ("setup", "clean_up", "required_programs")
def __init__(
self,
*,
setup: str = "",
clean_up: str = "",
required_programs: list[str] | None = None,
):
"Initialise the script for a VHS tape"
# Save all the given variables
self.setup: str = setup
self.clean_up: str = clean_up
self.required_programs: list[str] = (
required_programs if required_programs is not None else []
)
class VHSTape:
"A class to represent a VHS tape"
__slots__ = (
"name",
"file_name",
"files_and_directories",
"setup",
"clean_up",
"required_programs",
"shell_body",
"yazi_body",
"skip_quitting_yazi",
"editor",
)
def __init__(
self,
*,
name: str,
files_and_directories: list[str] | None = None,
scripts: list[Script] | None = None,
shell_body: list[str] | None = None,
yazi_body: list[str],
skip_quitting_yazi: bool = False,
editor: str | None = None,
):
"Initialise the VHS tape"
# Save all the given variables
self.name: str = name
self.file_name: str = name.lower().replace(" ", "_")
self.files_and_directories: list[str] = (
files_and_directories if files_and_directories is not None else []
)
self.shell_body: list[str] = shell_body if shell_body else []
self.yazi_body: list[str] = yazi_body
self.skip_quitting_yazi: bool = skip_quitting_yazi
self.editor: str | None = editor
# Set the setup script to an empty list if it is not given
scripts = scripts if scripts else []
# Initialise the setup scripts
self.setup: list[str] = []
# Initialise the clean up scripts
self.clean_up: list[str] = []
# Initialise the required programs
self.required_programs: set[str] = set()
# Iterate over the scripts
for script in scripts:
# Add the setup script
self.setup.append(script.setup)
# Add the clean up script
self.clean_up.append(script.clean_up)
# Add the required programs
self.required_programs.update(script.required_programs)
# Add yazi and clear to the required programs
# as they are required for all demos
self.required_programs.update(
[
"yazi",
"clear",
]
)
# Add the editor to the required programs if it is given
if self.editor:
self.required_programs.add(self.editor)
def __str__(self) -> str:
"Return the VHS tape as a string"
# The files and directories to clean up
files_and_directories_to_clean_up: set[str] = set()
# Iterate over the files and directories
for item in self.files_and_directories:
# Add the item with the trailing slashes removed
files_and_directories_to_clean_up.add(item.strip("/"))
# The path object for the item
path_object = Path(item)
# Get the file name and the file extension
file_name, file_extension = path_object.stem, path_object.suffix
# If the file extension is an archive file extension
if file_extension in ARCHIVE_FILE_EXTENSIONS:
# Add the item without the file extension
files_and_directories_to_clean_up.add(file_name)
# If the list of files and directories to clean up is not empty
if files_and_directories_to_clean_up:
# Append the rm command to the required programs
self.required_programs.add("rm")
# fmt: off
# The list of lines
lines: list[str] = [
# The output file for the VHS tape
f"Output videos/{self.file_name}.mp4",
# The required programs for the VHS tape
"\n".join(
[f'Require "{program}"' for program in self.required_programs]
),
# Configuration for the VHS tape
CONFIG,
# The set up for the VHS tape
"Hide",
FAST_TYPING_SPEED,
CHANGE_TO_WORKING_DIRECTORY,
"\n".join(self.setup),
CLEAR_SCREEN,
"Show",
# Set the normal typing speed
NORMAL_TYPING_SPEED,
# The shell body of the VHS tape
"\n".join(self.shell_body),
# Open the Yazi program
'Type "{}" Enter'.format(
f"EDITOR={self.editor} yazi" if self.editor else "yazi"
),
SLEEP_TIME,
# The yazi body of the VHS tape
"\n".join(self.yazi_body),
]
# fmt: on
# If quitting yazi is not skipped
if not self.skip_quitting_yazi:
# The commands to quit yazi
quit_yazi_commands = [
SLEEP_TIME,
'Type "q"',
SHORT_SLEEP_TIME,
]
# Add the commands to the VHS tape
lines.extend(quit_yazi_commands)
# If there are clean up commands,
# or there are files and directories to clean up
if self.clean_up or files_and_directories_to_clean_up:
# Set the clean up section
clean_up_section = [
"Hide",
FAST_TYPING_SPEED,
"\n".join(self.clean_up),
(
"Type 'rm -rf {}' Enter".format(
" ".join(files_and_directories_to_clean_up)
)
if files_and_directories_to_clean_up
else ""
),
]
# Add the clean up section to the lines
lines.extend(clean_up_section)
# The vhs tape
vhs_tape = "\n".join(lines).format(*self.files_and_directories).strip()
# Return the vhs tape
return vhs_tape
def to_string(self) -> str:
"Return the VHS tape as a string"
return self.__str__()
def get_file_path(self) -> str:
"Return the file name for the VHS tape"
return f"./vhs_tapes/{self.file_name}.tape"
def write_to_file(self) -> None:
"Write the VHS tape to a tape file"
# Open the file for writing
with open(self.get_file_path(), "w") as file:
# Write the VHS tape to the file
file.write(self.to_string())
@staticmethod
def edit_init_lua_config(
config_option: str,
value: int | float | str | bool,
original_value: int | float | str | None = None,
) -> Script:
"""
Return a script object that contains the
setup commands, the clean up commands, and the required programs
to edit the init.lua file for the demo.
"""
# Initialise the stringified value
stringified_value: str = str(value)
# Initialise the stringified original value
stringified_original_value: str = str(original_value)
# If the value given is a boolean
if isinstance(value, bool):
# Lower case the stringified value
stringified_value = stringified_value.lower()
# Set the stringified original value to the inverse of the value
stringified_original_value = str(not value).lower()
# Otherwise, if the original value is not given, throw an error
elif original_value is None:
raise ValueError("Original value not given for non-boolean value")
# The template for the set command
sed_command_template = r"sed -i 's/\({} = \)\w\+,/\1{},/' init.lua"
# The command to edit the configuration
edit_config_command = rf"Type `{sed_command_template}` Enter".format(
config_option, stringified_value
)
# The clean up command to undo the edit to the init.lua file
clean_up_edit_config_command = (
rf"Type `{sed_command_template}` Enter".format(
config_option, stringified_original_value
)
)
# Return the script object
return Script(
setup=edit_config_command,
clean_up=clean_up_edit_config_command,
required_programs=["sed"],
)
@staticmethod
def toggle_between_two_items(number_of_times: int) -> str:
"Return a command to quickly toggle the selection between two items"
return "\n".join(
[
"Ctrl+n",
VERY_SHORT_SLEEP_TIME,
"Ctrl+p",
VERY_SHORT_SLEEP_TIME,
]
* number_of_times
)
@staticmethod
def create_nested_archive(
number_of_nested_archives: int,
archive_file_name: str = "demo.zip",
nested_archive_file_name: str = "nested",
text_file_name: str = "demo.txt",
) -> Script:
"""
Returns a script object that contains the
setup commands, the clean up commands, and the required programs
to create the nested archive for the demo.
"""
# The list of the nested archive names
nested_archive_names_list = [
f"{nested_archive_file_name}-{number + 1}.zip"
for number in range(number_of_nested_archives)
]
# Create the commands to create the nested archives
nested_archive_commands = "\n".join(
[
f'Type "7z a {archive_name} {text_file_name}" Enter'
for archive_name in nested_archive_names_list
]
)
# Join the list of nested archive names with a space
nested_archive_names = " ".join(nested_archive_names_list)
# The command to create the test archive
create_test_archive_command = 'Type "7z a {} {}" Enter'.format(
f"{archive_file_name}",
nested_archive_names,
)
# The command to remove all of the extra archives and the file
clean_up_commands = 'Type "rm {} {}" Enter'.format(
text_file_name,
nested_archive_names,
)
# The command to create the nested archive
create_nested_archive_command = "\n".join(
[
f'Type `echo "test" > {text_file_name}` Enter',
nested_archive_commands,
create_test_archive_command,
clean_up_commands,
]
)
# Return the script object
return Script(
setup=create_nested_archive_command,
required_programs=["7z", "echo", "rm"],
)
@staticmethod
def create_multiple_nested_archives(
number_of_archives: int, number_of_nested_archives: int
) -> Script:
"""
Returns a script object that contains the
setup commands, the clean up commands, and the required programs
to create multiple nested archives for the demo.
"""
# Initialise the scripts for the setup
setup_scripts: list[str] = []
# Initialise the required programs
required_programs: list[str] = []
# Iterate over the number of archives to create
for number in range(number_of_archives):
# Create the nested archive
nested_archive = VHSTape.create_nested_archive(
number_of_nested_archives, "{" + str(number) + "}"
)
# If it is the first iteration,
# set the required programs
if number == 0:
required_programs = nested_archive.required_programs
# Add the setup script
setup_scripts.append(nested_archive.setup)
# Return the script object
return Script(
setup="\n".join(setup_scripts),
required_programs=required_programs,
)
@staticmethod
def create_keymap_toml(contents: str) -> Script:
"""
Returns a script object that contains the
setup commands, the clean up commands, and the required programs
to create the keymap.toml file for the demo.
"""
# Make the contents work with the VHS file format
fixed_contents = (
contents.strip()
.replace('"', '\\"')
.replace("\n", "` Enter\nType `")
.strip()
)
# The command to create the keymap.toml file
create_keymap_toml_command = "\n".join(
[
"Type `mv '../../keymap.toml' '../../keymap.toml.bak'` Enter",
f'Type `echo "{fixed_contents}" > ../../keymap.toml` Enter',
]
)
# The command to clean up the keymap.toml file
clean_up_keymap_toml_command = "\n".join(
[
"Type 'rm ../../keymap.toml' Enter",
"Type `mv '../../keymap.toml.bak' '../../keymap.toml'` Enter",
]
)
# Return the script object
return Script(
setup=create_keymap_toml_command,
clean_up=clean_up_keymap_toml_command,
required_programs=["mv", "echo", "rm"],
)
@staticmethod
def create_keymap_toml_keybind(key: str | int, command: str) -> str:
"Create a key bind in the keymap.toml file"
# The single keybind
keybind = "\n".join(
[
"[[manager.prepend_keymap]]",
f'on = [ "{key}" ]',
f"run = '''{PLUGIN_COMMAND_TEMPLATE}'''".format(command),
]
)
# Return the key bind
return keybind
@staticmethod
def create_extract_keymap_toml(key: str) -> Script:
"Create the keymap.toml file for the extract demo"
# The contents of the keymap.toml file
contents = VHSTape.create_keymap_toml_keybind(key, "extract")
# Return the script to create and clean up the keymap.toml file
return VHSTape.create_keymap_toml(contents)
@staticmethod
def create_shell_keymap_toml(
key: str, shell_command: str, flags: list[str]
) -> Script:
"Create the keymap.toml file for the shell command demo"
# Get the flags standardised for the shell command
standardised_flags = [
f"--{flag.replace(' ', '-').replace('_', '-').strip()}"
for flag in flags
]
# The shell command as an argument
shell_command = 'shell "{}" {}'.format(
shell_command,
" ".join(standardised_flags),
)
# The contents of the keymap.toml file
contents = VHSTape.create_keymap_toml_keybind(key, shell_command)
# Return the script to create and clean up the keymap.toml file
return VHSTape.create_keymap_toml(contents)
@staticmethod
def create_tab_switch_keymap_toml() -> Script:
"Create the keymap.toml file for the tab switch demo"
# Initialise the list containing the keybinds
keybinds: list[str] = []
# Iterate from 0 to 8
for number in range(9):
# Create the keybind
keybind = VHSTape.create_keymap_toml_keybind(
number + 1, f"tab_switch {number}"
)
# Add the keymap to the list
keybinds.append(keybind)
# Get the contents of the keymap.toml file
contents = "\n".join(keybinds)
# Return the script to create and clean up the keymap.toml file
return VHSTape.create_keymap_toml(contents)
@staticmethod
def press_key_repeatedly(
key: str,
number_of_times: int,
delay_in_ms: int = 250,
) -> str:
"Return the command to cycle through the tabs"
return 'Type@{}ms "{}"'.format(delay_in_ms, key * number_of_times)
# The dictionary containing the tapes for all demos
VHS_TAPES: list[VHSTape] = [
VHSTape(
name="Open prompt",
scripts=[
VHSTape.edit_init_lua_config("prompt", True),
],
yazi_body=[
'Type "/cspell.json" Enter',
"Space@300ms 3",
'Type "l"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
"Enter",
'Space Type "pb"',
LONG_SLEEP_TIME,
"Ctrl+c",
SHORT_SLEEP_TIME,
'Type ":q!" Enter',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type "s"',
SLEEP_TIME,
"Enter",
'Space Type "pb"',
VHSTape.toggle_between_two_items(3),
SHORT_SLEEP_TIME,
"Ctrl+c",
SHORT_SLEEP_TIME,
'Type ":q!" Enter',
],
),
VHSTape(
name="Open behaviour",
yazi_body=[
'Type "/cspell.json" Enter',
"Space@300ms 3",
'Type "l"',
SLEEP_TIME,
'Space Type "pb"',
LONG_SLEEP_TIME,
"Ctrl+c",
SHORT_SLEEP_TIME,
'Type ":q!" Enter',
SLEEP_TIME,
'Type "k"',
SHORT_SLEEP_TIME,
'Type "l"',
'Space Type "pb"',
VHSTape.toggle_between_two_items(3),
SHORT_SLEEP_TIME,
"Ctrl+c",
SHORT_SLEEP_TIME,
'Type ":q!" Enter',
],
),
VHSTape(
name="Open auto extract archives",
files_and_directories=["demo.zip"],
scripts=[
VHSTape.edit_init_lua_config("recursively_extract_archives", False),
VHSTape.create_nested_archive(4, "{0}"),
],
yazi_body=[
'Type "/{0}" Enter',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type "h"',
],
),
VHSTape(
name="Open recursively extract archives",
files_and_directories=["demo.zip"],
scripts=[
VHSTape.create_nested_archive(4, "{0}"),
],
shell_body=[
"Type `7z l {0}` Enter",
LONG_SLEEP_TIME,
],
yazi_body=[
'Type "/{0}" Enter',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type "h"',
],
),
VHSTape(
name="Extract must have hovered item",
files_and_directories=[
"demo-1.zip",
"demo-2.zip",
"demo-3.zip",
"demo-4.zip",
"demo-1",
],
scripts=[
VHSTape.edit_init_lua_config("recursively_extract_archives", False),
VHSTape.create_extract_keymap_toml(DEFAULT_KEY),
VHSTape.create_multiple_nested_archives(4, 4),
Script(
setup="\n".join(
[
'Type `mv "{}" "./.git/"` Enter'.format(
"{" + str(index) + "}"
)
for index in range(4)
]
),
clean_up="\n".join(
[
'Type `mv "./.git/{}" "./"` Enter'.format(
"{" + str(index) + "}"
)
for index in range(5)
]
),
required_programs=["mv"],
),
],
yazi_body=[
'Type "l"',
SLEEP_TIME,
'Type "/{0}" Enter',
SLEEP_TIME,
'Type "j"',
"Space@300ms 3",
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
LONG_SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "n"',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "/{4}" Enter',
],
),
VHSTape(
name="Extract hovered item optional",
files_and_directories=[
"demo-1.zip",
"demo-2.zip",
"demo-3.zip",
"demo-4.zip",
"demo-2",
"demo-3",
"demo-4",
"demo-1",
],
scripts=[
VHSTape.edit_init_lua_config("recursively_extract_archives", False),
VHSTape.edit_init_lua_config("must_have_hovered_item", False),
VHSTape.create_extract_keymap_toml(DEFAULT_KEY),
VHSTape.create_multiple_nested_archives(4, 4),
Script(
setup="\n".join(
[
'Type `mv "{}" "./.git/"` Enter'.format(
"{" + str(index) + "}"
)
for index in range(4)
]
),
clean_up="\n".join(
[
'Type `mv "./.git/{}" "./"` Enter'.format(
"{" + str(index) + "}"
)
for index in range(8)
]
),
required_programs=["mv"],
),
],
yazi_body=[
'Type "l"',
SLEEP_TIME,
'Type "/{0}" Enter',
SLEEP_TIME,
'Type "j"',
"Space@300ms 3",
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "/{4}" Enter',
SLEEP_TIME,
'Type "j"',
SLEEP_TIME,
'Type "j"',
SLEEP_TIME,
'Type "/{0}" Enter',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "/{7}" Enter',
],
),
VHSTape(
name="Extract prompt",
files_and_directories=[
"demo-1.zip",
"demo-2.zip",
"demo-3.zip",
"demo-4.zip",
"demo-4_1",
],
scripts=[
VHSTape.edit_init_lua_config("prompt", True),
VHSTape.create_extract_keymap_toml(DEFAULT_KEY),
VHSTape.create_multiple_nested_archives(4, 4),
],
yazi_body=[
'Type "/{0}" Enter',
SLEEP_TIME,
"Space@300ms 3",
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
"Enter",
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "s"',
SLEEP_TIME,
"Enter",
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
"Enter",
],
),
VHSTape(
name="Extract behaviour",
files_and_directories=[
"demo-1.zip",
"demo-2.zip",
"demo-3.zip",
"demo-4.zip",
"demo-5.zip",
],
scripts=[
VHSTape.create_extract_keymap_toml(DEFAULT_KEY),
VHSTape.create_multiple_nested_archives(5, 4),
],
yazi_body=[
'Type "/{0}" Enter',
SLEEP_TIME,
"Space@300ms 3",
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "j"',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "kk"',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
],
),
VHSTape(
name="Extract recursively extract archives",
files_and_directories=["demo.zip", "demo"],
scripts=[
VHSTape.create_extract_keymap_toml(DEFAULT_KEY),
VHSTape.create_nested_archive(4, "{0}"),
],
shell_body=[
"Type `7z l {0}` Enter",
LONG_SLEEP_TIME,
],
yazi_body=[
'Type "/{0}" Enter',
SLEEP_TIME,
f'Type "{DEFAULT_KEY}"',
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "/{1}" Enter',
SLEEP_TIME,
'Type "l"',
],
),
VHSTape(
name="Smart enter",
yazi_body=[
'Type "l"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "jl"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "jl"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "G"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type ":q!" Enter',
SLEEP_TIME,
'Type "kl"',
SLEEP_TIME,
'Type ":q!" Enter',
SLEEP_TIME,
'Type "kl"',
SLEEP_TIME,
'Type ":q!" Enter',
],
),
VHSTape(
name="Enter skip single subdirectory",
yazi_body=[
'Type "j"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
"Left",
SLEEP_TIME,
"Left",
],
),
VHSTape(
name="Leave skip single subdirectory",
scripts=[
Script(
setup="Type `cd './.github/workflows/'` Enter",
),
],
yazi_body=[
'Type "h"',
SLEEP_TIME,
"Right",
SLEEP_TIME,
"Right",
],
),
VHSTape(
name="Rename must have hovered item",
yazi_body=[
'Type "l"',
SLEEP_TIME,
'Type "j"',
"Space@300ms 3",
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "l"',
'Type "r"',
LONG_SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
'Type "r"',
"Backspace@300ms 3",
SLEEP_TIME,
"Ctrl+c",
],
),
VHSTape(
name="Rename hovered item optional",
scripts=[
VHSTape.edit_init_lua_config("must_have_hovered_item", False),
],
yazi_body=[
'Type "l"',
SLEEP_TIME,
'Type "j"',
"Space@300ms 3",
SLEEP_TIME,
'Type "gg"',
SLEEP_TIME,
'Type "l"',
SLEEP_TIME,
'Type "r"',
SLEEP_TIME,
'Type ":q!" Enter',
SLEEP_TIME,
'Type "h"',
],
),
VHSTape(
name="Rename prompt",
scripts=[
VHSTape.edit_init_lua_config("prompt", True),
],
yazi_body=[
'Type "/cspell.json" Enter',
"Space@300ms 3",
'Type "r"',
SLEEP_TIME,
'Type "h"',
SLEEP_TIME,
"Enter",
SLEEP_TIME,
"Escape",
'Type "b"',
SLEEP_TIME,
"Ctrl+c",
SLEEP_TIME,