-
Notifications
You must be signed in to change notification settings - Fork 0
/
slynkk
executable file
·114 lines (93 loc) · 4.98 KB
/
slynkk
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
#!/bin/python3
# Slynkk - The Python Shell
# 🄯 2023-2023, Hellscaped @ hellscaped.software
# All rights are reserved to you, the user.
# Feel free to extend Slynkk and share it with others.
# I'm going to document the api sometime in the future, but for now, you'll have to figure it out yourself.
import os, sys, time, subprocess, datetime, colorama, random, requests
SLYNKK_VERSION = "0.0.5"
# Initialize colorama
colorama.init()
logo = """
//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\
▒████▒ ████ ██ ██
▒██████ ████ ██ ██
██▒ ▒█ ██ ██ ██
██ ██ ██▓ ▓██ ██░████ ██ ▓██▒ ██ ▓██▒
███▒ ██ ▒██ ██▓ ███████▓ ██ ▓██▒ ██ ▓██▒
▒█████▒ ██ ██▒ ██░ ███ ▒██ ██▒██▒ ██▒██▒
░█████▒ ██ ███▒██ ██ ██ ████▓ ████▓
▒███ ██ ░██▓█▓ ██ ██ █████ █████
██ ██ ████░ ██ ██ ██░███ ██░███
█▒░ ▒██ ██▒ ▒███ ██ ██ ██ ██▒ ██ ██▒
███████▒ █████ ██▓ ██ ██ ██ ▒██ ██ ▒██
░█████▒ ░████ ██░ ██ ██ ██ ███ ██ ███
▒██
███▒
███
//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\//\\\\
Slynkk - The Python Shell
Created by Hellscaped @ hellscaped.software
"""
# colorize the logo
def bold(text):
return f"{colorama.Style.BRIGHT}{text}{colorama.Style.RESET_ALL}"
def color(text, color):
return f"{color}{text}{colorama.Fore.RESET}"
def getPrompt():
cwd = os.getcwd()
user = os.getlogin()
if os.getuid() == 0:
user = color("root", colorama.Fore.RED)
hostname = os.uname()[1]
time = datetime.datetime.now().strftime("%H:%M:%S")
return f"{bold('╔<')}{colorama.Style.BRIGHT}{colorama.Fore.GREEN}{user}{colorama.Fore.RESET}{colorama.Style.RESET_ALL}{colorama.Fore.RED}@{colorama.Style.BRIGHT}{colorama.Fore.GREEN}{hostname}{colorama.Fore.RESET}:{colorama.Fore.GREEN}{color(cwd,colorama.Fore.BLUE)}{colorama.Fore.RESET}{bold('>')}\n{bold('║')} {colorama.Fore.GREEN}Time: {time}{colorama.Fore.RESET}\n{bold('║')} \n{bold('╚════════════◸')} "
# colorize the logo
colors = [colorama.Fore.RED, colorama.Fore.GREEN, colorama.Fore.YELLOW, colorama.Fore.BLUE, colorama.Fore.MAGENTA, colorama.Fore.CYAN]
primary = color("█", colorama.Fore.CYAN)
secondary = color("▓", colorama.Fore.BLUE)
logo = logo.replace("█", primary)
logo = logo.replace("▓", secondary)
logo = logo.replace("▒", color("▒", colorama.Fore.RED))
logo = logo.replace("░", color("░", colorama.Fore.MAGENTA))
logo = bold(logo)
# set shell name to slynkk
os.environ["SHELL"] = "/bin/slynkk"
if len(sys.argv) == 1 or "--no-logo" in sys.argv:
os.system("clear")
if "--no-logo" not in sys.argv:
print(logo)
while True:
try:
command = input(getPrompt())
if command.split()[0] == "cd":
os.chdir(command.split()[1])
elif command == "exit":
break
else:
os.system(command)
except KeyboardInterrupt:
print()
pass
except:
pass
else:
args = sys.argv[1:]
if args[0] == "upgrade":
# check if there is an update
r = requests.get("https://raw.githubusercontent.com/SlynkkShell/Slynkk/main/version")
if r.status_code != 200:
print("Failed to check for updates.")
exit(1)
if r.text != SLYNKK_VERSION:
print("There is an update available!")
print("Updating...")
exitcode = os.system("curl -s https://raw.githubusercontent.com/SlynkkShell/Slynkk/master/update.sh | sudo bash")
if exitcode == -1:
print("Shell failed to update due to an error.")
elif exitcode == 1:
print("You aren't root!")
else:
print("Done!")
else:
print("You are already up to date!")