-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
486 lines (408 loc) · 22 KB
/
Main.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
import os
import shutil
import time
import pandas as pd
import numpy as np
from termcolor import colored, cprint
from alive_progress import alive_bar
from time import sleep
from tqdm import tqdm
# Global variables
df = pd.DataFrame(np.random.randint(0, 1000, (100000, 600)))
ascii_art_file = ""
ascii_art_header_visible = True
marker = "# === ASCIIStart modifications ==="
df = pd.DataFrame(np.random.randint(0, 1000, (100000, 600)))
headers_directory = "Headers"
current_header = "None"
header_counter = 1 # Counter for default header naming
bashrcSwitch = "~/.zshrc" #use ~/.bashrc for testing
def display_banner():
ascii_art = """
______ ______ ______ ______ ______ ______ __ __
/ \ / \ / \ | \| \ / \ | \ | \
| $$$$$$\| $$$$$$\| $$$$$$\ \$$$$$$ \$$$$$$| $$$$$$\ _| $$_ ______ ______ _| $$_
| $$__| $$| $$___\$$| $$ \$$ | $$ | $$ | $$___\$$| $$ \ | \ / \| $$ \
| $$ $$ \$$ \ | $$ | $$ | $$ \$$ \ \$$$$$$ \$$$$$$\| $$$$$$ $$$$$$
| $$$$$$$$ _\$$$$$$\| $$ __ | $$ | $$ _\$$$$$$\ | $$ __ / $$| $$ \$$ | $$ __
| $$ | $$| \__| $$| $$__/ \ _| $$_ _| $$_ | \__| $$ | $$| \| $$$$$$$| $$ | $$|
| $$ | $$ \$$ $$ \$$ $$| $$ \| $$ \ \$$ $$ \$$ $$ \$$ $$| $$ \$$ $$
\$$ \$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$ \$$$$$$$ \$$ \$$$$
"""
if ascii_art_header_visible:
cprint(ascii_art, "cyan")
cprint(""" Created by: SYR3
""", "light_magenta")
def display_options():
options = [
"\n1. Add ASCII Header",
"2. Update Header",
"3. Edit Headers",
"4. Remove Headers",
"5. Help",
"6. Exit"
]
cprint("Select an option to get started:", "red")
for option in options:
cprint(option, "yellow")
def colored_input(prompt, color):
cprint(prompt, color, end='')
return input().strip().lower()
def ensure_headers_directory():
if not os.path.exists(headers_directory):
os.makedirs(headers_directory)
def list_headers():
ensure_headers_directory()
return os.listdir(headers_directory)
def display_header_list():
headers = list_headers()
if not headers:
cprint("No headers found.", "red")
return False
cprint("Available headers:", "cyan")
for idx, header in enumerate(headers, start=1):
if header == current_header:
cprint(f"\n {idx}. {header} (current)", "green")
else:
cprint(f"\n {idx}. {header}", "yellow")
return True
def add_ascii_header():
global header_counter
while True:
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
cprint('\n INSTRUCTIONS', "red")
cprint('\n1. Create or add your custom ascii art file into ASCIIStart folder.', "yellow")
cprint('\n2. Type in the name of the saved file and click enter.', "yellow")
cprint("\n3. Rename new file when propmted. (optional)", "yellow")
cprint("\n4. Done! All newly added headers will be saved to ./headers.", "yellow")
cprint("\n")
# Reset header counter if no files exist in the directory
if not list_headers():
header_counter = 1
file_path = colored_input("\nEnter file name or type 'back' to return: ", "cyan")
if file_path == 'back':
return
if os.path.isfile(file_path):
default_header_name = f"head_{header_counter:02}.txt"
header_counter += 1
print("\n")
cprint("Copying file to Headers folder!", "light_magenta")
ascii_art_file = file_path
# Progress Bar
with alive_bar(200, bar = 'bubbles', spinner = 'notes2') as bar:
for i in range(200):
sleep(0.03)
bar()
cprint(f"Complete!","green")
time.sleep(2)
ensure_headers_directory()
new_header_path = os.path.join(headers_directory, default_header_name)
shutil.copy(file_path, new_header_path)
while True:
rename_choice = colored_input("Would you like to rename this file? (y/n): ", "cyan")
if rename_choice == 'y':
new_name = colored_input("\nEnter name (without extension): ", "yellow")
new_header_path = os.path.join(headers_directory, f"{new_name}.txt")
os.rename(os.path.join(headers_directory, default_header_name), new_header_path)
cprint(f"\nFile renamed to: {new_name}.txt", "white")
time.sleep(2)
cprint("Returning...", "red")
break
elif rename_choice == 'n':
cprint(f"\nFile saved as: {default_header_name}", "white")
time.sleep(2)
cprint("Returning...", "red")
break
else:
cprint("\nInvalid input. Please enter 'y' or 'n'.", "red")
cprint("""
⢀⣤⣶⣶⣤⣄⡀
⠀⢀⣿⣿⣿⣿⣿⣿⣿⡆
⠀⠸⣿⣿⣿⣿⣿⡟⡟⡗ ⣿⠉⣿⠉⣿⡏⠹⡏⢹⡏⢹⣿⣿⠉⣿⠉⣿⡟⢋⠛⣿⠉⡟⢉⡏⠹⠏⣹⣿
⠀⠀⠙⠏⠯⠛⣉⢲⣧⠟ ⣿⠄⣿⠄⣿⡇⡄⠁⢸⡇⢸⣿⣿⠄⣿⠄⣿⠄⣿⣿⣿⠄⡀⢻⣿⡄⢠⣿⣿
⠀⠀⠠⢭⣝⣾⠿⣴⣿⠇ ⣿⣦⣤⣴⣿⣧⣿⣤⣼⣧⣬⣭⣿⣦⣤⣴⣿⣧⣤⣤⣿⣤⣷⣤⣿⣧⣼⣿⣿
⠀⠀⢐⣺⡿⠁⠀⠈⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⣶⣶⣶⣶⣶⣶⠀
⠀⠀⣚⣿⠃ ⣶⣶⣶⣶
⢀⣿⣿⣿⣷⢒⣢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣶⣶⣄⠄
⢰⣿⣿⡿⣿⣦⠬⢝⡄⠀⠀⠀⠀⠀⠀⢠⣿⠿⠿⠟⠛⠋⠁
⠠⢿⣿⣷⠺⣿⣗⠒⠜⡄⠀⠀⠀⠀⣴⠟⠁
⠀⣰⣿⣷⣍⡛⣯⣯⣙⡁⠀⠀⣠⡾⠁
⠀⠨⢽⣿⣷⢍⣛⣶⢷⣼⣠⣾⠋
⠀⠀⠘⢿⣿⣖⠬⣹⣶⣿⠟⠁
⠀⠀⠀⠚⠿⠿⡒⠨⠛⠋
⠀⠀⠀⠐⢒⣛⣷
⠀⠀⠀⢘⣻⣭⣭
⠀⠀⠀⡰⢚⣺⣿
⠀⠀⢠⣿⣿⣿⣿⣦⡄
⠀⠀⢸⡿⢿⣿⢿⡿⠃
⠀⠀⠘⡇⣸⣿⣿⣿⣆
⠀⠀⠀⠀⠸⣿⡿⠉⠁
⠀⠀⠀⠀⠀⢿⡟
""", "dark_grey")
cprint("Invalid input. Please enter 'y' or 'n'.", "red")
print("\n")
time.sleep(1.5) # Delay to show confirmation message
break
else:
cprint("\nInvalid file path. Please enter a valid file path.", "red")
cprint("""
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡶⠛⠛⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠋⠀⠀⠀⠈⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⢀⣠⠴⠞⠛⠉⠉⠉⠉⠉⠉⠛⠒⠾⢤⣀⠀⣀⣠⣤⣄⡀⠀⠀⠀
⠀⠀⠀⣠⡶⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢭⡀⠀⠈⣷⠀⠀⠀
⠀⠀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⢀⡟⠀⠀⠀
⠀⣾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⡅⠀⠀⠀
⢸⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣄⣀⠀
⣾⠀⠀⣠⣤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣄⠀⠀⠀⠀⠀⠀⠸⡇⠉⣷
⣿⠀⠰⣿⣿⣿⡗⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣧⡴⠋
⣿⠀⠀⢸⠛⢫⠀⠀⢠⠴⠒⠲⡄⠀⠀⠀⠀⡝⠛⢡⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀
⢸⡄⠀⢸⡀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢸⠀⠀⠀⠀⠀⠀⡼⣄⠀⠀
⠀⢳⡄⠀⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠀⢸⠀⠀⠀⠀⢀⡼⠁⢸⡇⠀
⠀⠀⠙⢦⣷⡈⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠈⡇⠀⣀⡴⠟⠒⠚⠋⠀⠀
⠀⠀⠀⠀⠈⠛⠾⢤⣤⣀⣀⡀⠀⠀⠀⠀⣀⣈⣇⡤⣷⠚⠉⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣰⠇⠀⠩⣉⠉⠉⠉⣩⠍⠁⠀⢷⣟⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡟⠐⠦⠤⠼⠂⠀⠸⠥⠤⠔⠂⠘⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣸⣧⡟⠳⠒⡄⠀⠀⠀⡔⠲⠚⣧⣀⣿⠿⠷⣶⡆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠻⣄⢀⠀⠀⡗⠀⠀⠀⡇⠄⢠⠀⣼⠟⠀⢀⣨⠇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠙⢶⠬⠴⢧⣤⣤⣤⣽⣬⡥⠞⠛⠛⠋⠉⠀⠀⠀⠀⠀⠀⠀
""","light_magenta")
cprint("Invalid file path. Please enter a valid file path.", "red")
time.sleep(1.5) # Add delay to allow the user to read the error message
def display_header_list():
headers = list_headers()
if not headers:
cprint("\nNo headers found.", "red")
cprint("""
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠴⠒⠒⠲⠤⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡴⠋⠀⠀⠀⠀⠠⢚⣂⡀⠈⠲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⡀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⡴⠆⠀⠀⠀⠀⠀⢎⠐⢟⡇⠀⠈⢣⣠⠞⠉⠉⠑⢄⠀⠀⣰⠋⡯⠗⣚⣉⣓⡄
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⢠⢞⠉⡆⠀⠀⠀⠀⠀⠓⠋⠀⠀⠀⠀⢿⠀⠀⠀⠀⠈⢧⠀⢹⣠⠕⠘⢧⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠘⠮⠔⠁⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠈⣇⠀⢳⠀⠀⠘⡆⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡴⠋⠉⠓⠦⣧⠀⠀⠀⠀⢦⠤⠤⠖⠋⠇⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠸⡄⠈⡇⠀⠀⢹⡀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠙⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠈⣆⠀⠀⠀⢱⠀⡇⠀⠀⠀⡇⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠀⠀⠀⠀⠀⠀⠘⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⠸⡄⠀⠀⠀⠳⠃⠀⠀⠀⡇⠀
⠀⠀⠀⠀⠀⢠⢏⠉⢳⡀⠀⠀⢹⠀⠀⠀⠀⢠⠀⠀⠀⠑⠤⣄⣀⡀⠀⠀⠀⠀⠀⣀⡤⠚⠀⠀⠀⠀⠀⢸⢢⡀⠀⠀⠀⠀⠀⢰⠁⠀
⠀⠀⣀⣤⡞⠓⠉⠁⠀⢳⠀⠀⢸⠀⠀⠀⠀⢸⡆⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⢸⠀⠙⠦⣤⣀⣀⡤⠃⠀⠀
⠀⣰⠗⠒⣚⠀⢀⡤⠚⠉⢳⠀⠈⡇⠀⠀⠀⢸⡧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠸⠵⡾⠋⠉⠉⡏⠀⠀⠀⠈⠣⣀⣳⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠹⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠳⡄⠀⠀⠀⠀⠀⠀⠀⡰⠁⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⠲⠤⠤⠤⠴⠚⠁⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
""", "red")
cprint("\nNo headers found.", "red")
sleep(1.5)
return False
cprint("\nAvailable headers:", "red")
for idx, header in enumerate(headers, start=1):
if header == current_header:
cprint(f" {idx}. {header} (current)", "green")
else:
cprint(f"\n {idx}. {header}", "yellow") # Changed list color to purple (magenta)
return True
def update_header():
global current_header
while True:
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
if not display_header_list():
time.sleep(2)
return
headers = list_headers()
ct = print("")
header_input = colored_input("\nChoose header or type 'back' to return: ", "blue")
if header_input == 'back':
return
try:
header_index = int(header_input) - 1
header_name = headers[header_index]
header_path = os.path.join(headers_directory, header_name)
if os.path.isfile(header_path):
try:
with open(header_path, 'r') as file:
lines = file.readlines()
os.system('cls' if os.name == 'nt' else 'clear') # Clear the screen before loading progress bar
display_banner()
# Modify .bashrc to add the selected header
with open(os.path.expanduser(bashrcSwitch), 'a') as zshrc:
zshrc.write(f"\n{marker}\n")
for line in lines:
zshrc.write(f'echo "{line.rstrip()}"\n')
zshrc.write(f"# === End of ASCIIStart modifications ===\n")
cprint("\nModifying heder file ...", "light_magenta")
# Progress Bar
with alive_bar(200, bar='bubbles', spinner='notes2') as bar:
for i in range(100):
sleep(0.03)
bar()
cprint("Updating terminal header...", "light_magenta")
# Progress Bar
with alive_bar(200, bar='bubbles', spinner='notes2') as bar:
for i in range(100):
sleep(0.03)
bar()
current_header = header_name
cprint(f"Update Complete!", "green")
cprint(f"\nThe current header is now set to: {header_name}", "white")
time.sleep(3.5)
cprint("Returning...", "red")
time.sleep(2)
break
except Exception as e:
cprint(f"An error occurred: {e}", "red")
else:
cprint("Invalid header index. Please enter a valid index.", "red")
except ValueError:
cprint("Invalid input. Please enter a valid index number.", "red")
time.sleep(2) # Add delay to allow the user to read the error message
def edit_headers():
while True:
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
if not display_header_list():
time.sleep(2)
return
headers = list_headers()
choice = colored_input("\nChoose file to edit or type 'back' to return: ", "blue").lower()
if choice == 'back':
return
try:
header_index = int(choice) - 1
if 0 <= header_index < len(headers):
header_name = headers[header_index]
header_path = os.path.join(headers_directory, header_name)
if os.path.isfile(header_path):
available_editors = ["nano", "vim", "gedit", "notepad", "code"] # List of common text editors
editor_found = False
for editor in available_editors:
if shutil.which(editor):
os.system(f"{editor} {header_path}")
editor_found = True
break
if not editor_found:
cprint("\nNo available text editor found. Please install a text editor (e.g., nano, vim, gedit, notepad, code).", "red")
else:
cprint(f"\nEdits to {header_name} are saved.", "green")
time.sleep(2)
else:
cprint("Invalid header index. Please enter a valid index.", "red")
else:
cprint("Invalid header index. Please enter a valid index.", "red")
except ValueError:
cprint("Invalid input. Please enter a valid index number.", "red")
time.sleep(2) # Add delay to allow the user to read the error message
def remove_headers():
while True:
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
if not display_header_list():
time.sleep(2)
return
headers = list_headers()
choice = colored_input("\nEnter header to remove or type 'back' to return: ", "blue").lower()
if choice == 'back':
return
try:
header_index = int(choice) - 1
if 0 <= header_index < len(headers):
header_name = headers[header_index]
header_path = os.path.join(headers_directory, header_name)
if header_name == current_header:
cprint("\nCannot remove the current header. Please set a different current header first.", "red")
cprint("""
⣿⣿⡿⣫⣾⠏⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣀⣀⣀⠄⠄⠄⠄⠄⠄
⣿⡇⠱⠉⠁⠄⠄⠄⠄⠄⠄⢀⣀⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣦⠄⠄⠄⠄⠄
⣿⡇⠄⠄⠄⠄⠄⢀⣠⣛⡩⣩⣭⡹⣿⣿⣿⣿⠞⣛⣛⣛⡲⣿⡇⠄⠄⠄⠄
⣿⡇⠄⠄⠄⡾⣡⣾⣿⣷⣹⣿⣿⡿⣪⡻⠟⣱⣿⣿⣿⣿⣿⣷⡹⠄⠄⠄⠄
⣿⡇⠄⠄⣼⡇⣿⣻⣿⠟⡛⢿⣿⣾⣿⡇⢰⣍⢻⡿⠛⢿⣿⡭⣿⣷⠄⠄⠄
⣿⣧⣄⡀⣿⡇⣮⣽⣿⣮⣉⣾⣿⣿⣿⣇⡸⣿⣿⣆⠛⣰⣿⣾⡿⣿⠄⠄⠄
⣿⣇⡼⣄⣿⣿⡄⠙⢿⣏⣿⣿⡮⠁⣉⣾⣷⡈⠃⢿⣿⣬⡭⠝⣀⣿⠄⠄⠐
⡆⡇⣹⣿⣿⣿⣿⡿⠓⠛⣉⣉⣉⣉⣙⣛⠓⠾⣟⢿⣿⣿⣿⣿⣿⣿⣿⠇⠄⠙
⠁⡇⣞⣿⡿⠋⠁⠄⠄⠈⠉⠙⠛⠛⠻⠿⠿⠿⣶⣌⠻⣿⣿⣿⣿⣿⢗⢴⣆⢣
⠸⣇⡻⠈⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⢻⣷⡌⢿⣿⣿⣿⢸⠼⣣⣾
⣦⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠄⠄⠄⠄⠄⠄⠄⠄⠙⠛⠈⣿⡫⡼⢠⣾⣿⣿
⣿⣇⠄⣀⣠⡀⠄⠄⠴⠾⠿⠿⠶⠶⣦⣤⡀⠄⠄⠄⠄⠄⠄⢨⠯⢁⣿⣿⣿⣿
⣿⣿⣦⢒⠤⣅⡶⣶⣶⣾⣿⣿⣿⣷⣶⣮⣍⠢⠄⠄⠄⠄⠄⠐⢠⣾⣿⣿⣿⣿
⣿⣿⣿⣧⡐⠫⣉⡿⣬⡞⢿⣿⢯⠽⣶⡽⢟⣛⢖⣨⣛⠛⢃⣴⣿⣿⣿⣿⣿⣿
""", "red")
cprint("Cannot remove the current header. Please set a different current header first.", "red")
else:
if os.path.isfile(header_path):
try:
# Remove header from .bashrc
print("\n")
os.system(f"sed -i -e '/^echo /d' -e '/^# /d' {bashrcSwitch}")
# Delete header file from Headers directory
os.remove(header_path)
cprint("\nRemoving header from headers directory", "light_magenta")
# Progress Bar
with alive_bar(50, bar='bubbles', spinner='notes2') as bar:
for i in range(50):
sleep(0.03)
bar()
cprint("\nRemoving header from system file", "light_magenta")
# Progress Bar
with alive_bar(100, bar='bubbles', spinner='notes2') as bar:
for i in range(100):
sleep(0.03)
bar()
cprint(f"\n{header_name} has been removed from both Headers directory and system file!", "green")
time.sleep(2)
except Exception as e:
cprint(f"An error occurred: {e}", "red")
else:
cprint("Header file not found.", "red")
else:
cprint("Invalid header index. Please enter a valid index.", "red")
except ValueError:
cprint("Invalid input. Please enter a valid index number.", "red")
time.sleep(2) # Add delay to allow the user to read the error message
def display_help():
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
cprint("Help - ASCII Header Manager", "red")
help_text = """
1. Add ASCII Header:
- Allows you to add a new ASCII header from a file.
-
2. Update Header:
- Sets a selected header as the current header on terminal and adds it to system file.
- Each line is prefixed with echo " and suffixed with ".
- Includes a comment tracker for easier removal from system file..
3. Edit Headers:
- Opens the selected header file in a text editor for editing.
- Requires a text editor installed (e.g., nano, vim, gedit, notepad, code).
4. Remove Headers:
- Deletes the selected header file from both Headers directory and system file.
5. Help:
- Displays this help page with basic commands and usage of the program.
6. Exit:
- Closes the program.
Footer text: Buy me a coffee
"""
cprint(help_text, "yellow")
if __name__ == "__main__":
ensure_headers_directory()
while True:
os.system('cls' if os.name == 'nt' else 'clear')
display_banner()
display_options()
choice = colored_input("\nEnter your choice: ", "blue")
if choice == '1':
add_ascii_header()
elif choice == '2':
update_header()
elif choice == '3':
edit_headers()
elif choice == '4':
remove_headers()
elif choice == '5':
display_help()
colored_input("\nPress Enter to return to the main menu: ", "blue")
elif choice == '6' or choice == 'exit':
cprint("Exiting the program. Goodbye!", "red")
break
else:
cprint("Invalid choice. Please enter a number from 1 to 6 or 'exit'.", "red")
time.sleep(2) # Add delay to allow the user to read the error message