#!/usr/bin/python import os import socket import subprocess from colorama import Fore initDirectory = os.path.dirname(os.path.realpath(__file__)) currentDirectory = initDirectory version = "0.0.1" user = os.getlogin() print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version) argList = ["", ""] try: while True: command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ") argNumber = 0 argList.clear() for letter in command: if letter == " ": argNumber = argNumber + 1 else: try: argList[argNumber] = argList[argNumber] + letter except Exception: argList.append(letter) if argList[0] == "help": print("This is Mash, Max's Shell. Mash has a few built in commands, which you can use to run commands, view files and interact with your system.") print("Some commands you can run:") print("") print("pwd Print directory you are currently in") print("cd Change your directory.") print("cat View contents of a file.") print("version Print current version of Mash.") print("exit Exit Mash.") print("") print("You can also run commands installed by your system. See your OS's documentation for more information.") elif argList[0] == "exit": exit() elif argList[0] == "version": print(version) else: try: subprocess.run(argList) except Exception: print("Command", command, "either doesn't exist, isn't in the path or isn't in this directory.") #except Exception: # print("Looks like there was an error. Exiting...") except KeyboardInterrupt: print(" detected! Exiting...")