-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphell.py
More file actions
42 lines (34 loc) · 1007 Bytes
/
phell.py
File metadata and controls
42 lines (34 loc) · 1007 Bytes
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
# /usr/bin/env python
import sys, subprocess, phellFunctions
# NOTE get environment variables list
builtIns = []
for functions in dir(phellFunctions):
if "__" not in functions:
builtIns.append(functions)
while True:
command = input("$ ").split()
if not command: continue
# NOTE Default to os applications
if command[0] in builtIns:
match command[0]:
# Navigation
case "cd":
phellFunctions.cd(command)
case "ls":
phellFunctions.ls(command)
case "pwd":
phellFunctions.pwd()
# Interaction
case "echo":
phellFunctions.echo(command)
case "type":
pass
# Files
case "cat":
pass
elif command[0] == "exit": exit()
else:
try:
subprocess.run(command)
except Exception as e:
sys.stdout.write(f"{command[0]} isn't in PATH")