-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
156 lines (138 loc) · 7.69 KB
/
Copy pathindex.py
File metadata and controls
156 lines (138 loc) · 7.69 KB
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
import tkinter as tk
from tkinter import ttk
import tkinter.font as font
import subprocess
import os
from datetime import datetime
class TerminalApp:
def __init__(self, root):
self.root = root
self.root.title("Feather Terminal")
self.root.geometry("800x600")
self.current_theme = 'One Dark Pro'
self.configure_theme(self.current_theme)
# Register custom font
self.font_path = './font/font.ttf'
self.root.tk.call('font', 'create', 'customFont', '-family', 'Helvetica', '-size', '12')
self.custom_font = font.Font(family='customFont')
self.command_frame = tk.Frame(root, bg=self.theme['bg'])
self.command_frame.pack(pady=10, fill='x')
self.prompt_label = tk.Label(self.command_frame, text=self.get_prompt(), fg=self.theme['fg'], bg=self.theme['bg'], font=self.custom_font)
self.prompt_label.pack(side='left')
self.command_entry = tk.Entry(self.command_frame, bg=self.theme['bg'], fg=self.theme['fg'], insertbackground=self.theme['fg'], borderwidth=0, font=self.custom_font)
self.command_entry.pack(side='left', fill='x', expand=True)
self.command_entry.bind("<Return>", self.execute_command)
self.output_text = tk.Text(root, wrap='word', bg=self.theme['bg'], fg=self.theme['fg'], insertbackground=self.theme['fg'], borderwidth=0, font=self.custom_font)
self.output_text.pack(pady=10, expand=True, fill='both')
self.show_welcome_message()
def configure_theme(self, theme_name):
themes = {
'One Dark Pro': {'bg': '#282C34', 'fg': 'white'},
'Gruvbox Dark': {'bg': '#282828', 'fg': '#EBDBB2'},
'Terminal Hacker': {'bg': 'black', 'fg': 'green'},
'Monokai': {'bg': '#272822', 'fg': '#F8F8F2'},
'Sixten': {'bg': '#232627', 'fg': '#89DDFF'}
}
self.theme = themes.get(theme_name, themes['One Dark Pro'])
def get_prompt(self):
return os.getcwd() + "$ "
def execute_command(self, event=None):
command = self.command_entry.get().strip()
if command:
if command == "cls":
self.output_text.delete("1.0", tk.END)
elif command == "widgets::time":
self.show_time_widget()
elif command.startswith("theme::q"):
self.change_theme(command.split("::q")[1].strip())
else:
self.run_system_command(command)
self.output_text.insert(tk.END, self.get_prompt() + command + "\n")
self.command_entry.delete(0, tk.END)
self.prompt_label.config(text=self.get_prompt())
def run_system_command(self, command):
try:
if command == "ls" or command == "ls -l":
output = subprocess.run("dir" if os.name == 'nt' else command, shell=True, check=True, capture_output=True, text=True)
elif command.startswith("man "):
self.output_text.insert(tk.END, "Manual pages are not available.\n")
return
elif command == "more":
self.output_text.insert(tk.END, "Use 'less' or 'cat' instead.\n")
return
elif command.startswith("touch "):
open(command.split(" ")[1], 'a').close()
output = subprocess.run("dir" if os.name == 'nt' else "ls", shell=True, check=True, capture_output=True, text=True)
elif command.startswith("cat "):
file_path = command.split(" ")[1]
with open(file_path, 'r') as file:
self.output_text.insert(tk.END, file.read() + "\n")
return
elif command.startswith("obj "):
self.output_text.insert(tk.END, "Object command not implemented.\n")
return
elif command.startswith("rm "):
os.remove(command.split(" ")[1])
output = subprocess.run("dir" if os.name == 'nt' else "ls", shell=True, check=True, capture_output=True, text=True)
elif command.startswith("rmdir "):
os.rmdir(command.split(" ")[1])
output = subprocess.run("dir" if os.name == 'nt' else "ls", shell=True, check=True, capture_output=True, text=True)
else:
output = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
self.output_text.insert(tk.END, output.stdout)
except subprocess.CalledProcessError as e:
self.output_text.insert(tk.END, e.stderr)
except FileNotFoundError as e:
self.output_text.insert(tk.END, str(e) + "\n")
def change_theme(self, theme_name):
self.configure_theme(theme_name)
self.root.configure(bg=self.theme['bg'])
self.command_frame.configure(bg=self.theme['bg'])
self.prompt_label.configure(fg=self.theme['fg'], bg=self.theme['bg'])
self.command_entry.configure(bg=self.theme['bg'], fg=self.theme['fg'], insertbackground=self.theme['fg'])
self.output_text.configure(bg=self.theme['bg'], fg=self.theme['fg'], insertbackground=self.theme['fg'])
self.output_text.insert(tk.END, f"Theme changed to {theme_name}\n")
def show_time_widget(self):
self.output_text.delete("1.0", tk.END) # Clear screen
now = datetime.now()
time_str = now.strftime("%H:%M:%S")
date_str = now.strftime("%A, %B %d, %Y")
self.output_text.tag_configure('center', justify='center')
self.output_text.insert(tk.END, "\n\n\n", 'center')
self.output_text.insert(tk.END, time_str + "\n", 'center')
self.output_text.insert(tk.END, date_str + "\n", 'center')
def show_welcome_message(self):
feather_art = """
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶⣿⣽⣶⣾⣿⣿⣿⣿⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠂⣰⣿⣿⡿⠟⠋⣿⣿⣿⣿⣿⣿⠏⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⣿⣣⣾⡿⠛⢉⣤⣶⣿⣿⣿⣿⣿⡿⠃⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡄⣿⣿⣿⠟⢁⣤⣾⣿⣿⣿⣿⣿⣭⠥⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣷⡿⠋⣀⣴⣿⣿⣿⣿⣿⣷⠌⠉⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⠟⢀⣼⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣾⣿⣿⡿⠃⣰⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠰⣄⣾⣿⣿⡿⠁⣼⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣀⢻⣿⣿⡟⢀⣾⣿⢻⣿⠻⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠙⢿⣿⡿⠀⣾⣿⣿⠈⠟⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠉⠀
"""
self.output_text.insert(tk.END, feather_art, 'centered')
# Apply rainbow colors to "FEATHER"
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
feather_text = "FEATHER"
for i, char in enumerate(feather_text):
color = colors[i % len(colors)]
tag_name = f"color{i}"
self.output_text.tag_configure(tag_name, foreground=color)
self.output_text.insert(tk.END, char, tag_name)
self.output_text.insert(tk.END, "\n\n")
# Center the text
self.output_text.tag_configure('centered', justify='center')
self.output_text.tag_add('centered', "1.0", "end")
if __name__ == "__main__":
root = tk.Tk()
app = TerminalApp(root)
root.mainloop()