Update cd with new features
This commit is contained in:
parent
40519505be
commit
fc59ce8717
23
main.py
23
main.py
|
@ -3,18 +3,20 @@ import os
|
|||
import socket
|
||||
import subprocess
|
||||
from colorama import Fore
|
||||
from os.path import expanduser
|
||||
|
||||
initDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
currentDirectory = initDirectory
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
user = os.getlogin()
|
||||
|
||||
print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version)
|
||||
initDirectory = expanduser("~")
|
||||
currentDirectory = initDirectory
|
||||
|
||||
argList = ["", ""]
|
||||
|
||||
print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version)
|
||||
|
||||
try:
|
||||
while True:
|
||||
os.chdir(currentDirectory)
|
||||
command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ")
|
||||
argNumber = 0
|
||||
argList.clear()
|
||||
|
@ -41,6 +43,17 @@ try:
|
|||
exit()
|
||||
elif argList[0] == "version":
|
||||
print(version)
|
||||
elif argList[0] == "cd":
|
||||
try:
|
||||
directoryForCD = argList[1]
|
||||
if directoryForCD[0] == "~":
|
||||
currentDirectory = expanduser("~") + directoryForCD.replace("~", "")
|
||||
if directoryForCD[0] == "/":
|
||||
currentDirectory = directoryForCD
|
||||
else:
|
||||
currentDirectory = (currentDirectory + "/" + directoryForCD)
|
||||
except Exception:
|
||||
print("Either a directory was not provided or an error occured.")
|
||||
else:
|
||||
try:
|
||||
subprocess.run(argList)
|
||||
|
|
Loading…
Reference in New Issue
Block a user