Add built in "cat" (mat) and "ls" (mls)
This commit is contained in:
parent
fc59ce8717
commit
9136168689
19
main.py
Executable file → Normal file
19
main.py
Executable file → Normal file
|
@ -2,6 +2,7 @@
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
|
|
||||||
|
@ -12,6 +13,12 @@ currentDirectory = initDirectory
|
||||||
|
|
||||||
argList = ["", ""]
|
argList = ["", ""]
|
||||||
|
|
||||||
|
if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == True:
|
||||||
|
configFile = open(expanduser("~") + "/.config/mash/mash.conf")
|
||||||
|
else:
|
||||||
|
print("Config file does not exist. Copying default file to ~/.config/mash/mash.conf")
|
||||||
|
shutil.copyfile("/etc/mash/mash.conf", (expanduser("~") + "/.config/mash/mash.conf"))
|
||||||
|
|
||||||
print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version)
|
print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -34,7 +41,8 @@ try:
|
||||||
print("")
|
print("")
|
||||||
print("pwd Print directory you are currently in")
|
print("pwd Print directory you are currently in")
|
||||||
print("cd Change your directory.")
|
print("cd Change your directory.")
|
||||||
print("cat View contents of a file.")
|
print("mat View contents of a file. If you're on a Unix-like OS, use 'cat' instead.")
|
||||||
|
print("mls View all files in a directory. If you're on a Unix-like OS, use 'ls' instead.")
|
||||||
print("version Print current version of Mash.")
|
print("version Print current version of Mash.")
|
||||||
print("exit Exit Mash.")
|
print("exit Exit Mash.")
|
||||||
print("")
|
print("")
|
||||||
|
@ -43,6 +51,11 @@ try:
|
||||||
exit()
|
exit()
|
||||||
elif argList[0] == "version":
|
elif argList[0] == "version":
|
||||||
print(version)
|
print(version)
|
||||||
|
elif argList[0] == "mat":
|
||||||
|
matFile = open(argList[1])
|
||||||
|
print(matFile.read())
|
||||||
|
elif argList[0] == "mls":
|
||||||
|
os.listdir(currentDirectory)
|
||||||
elif argList[0] == "cd":
|
elif argList[0] == "cd":
|
||||||
try:
|
try:
|
||||||
directoryForCD = argList[1]
|
directoryForCD = argList[1]
|
||||||
|
@ -59,7 +72,7 @@ try:
|
||||||
subprocess.run(argList)
|
subprocess.run(argList)
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Command", command, "either doesn't exist, isn't in the path or isn't in this directory.")
|
print("Command", command, "either doesn't exist, isn't in the path or isn't in this directory.")
|
||||||
#except Exception:
|
except Exception:
|
||||||
# print("Looks like there was an error. Exiting...")
|
print("Looks like there was an error. Exiting...")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(" detected! Exiting...")
|
print(" detected! Exiting...")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user