From c4b0d5e95095413d0ae57c42b9db30976ead90a7 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Wed, 24 Jul 2024 14:45:40 +1000 Subject: [PATCH] Add colour config compatibility --- main.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 00f0a4e..cb002f5 100755 --- a/main.py +++ b/main.py @@ -6,9 +6,7 @@ import os import socket import subprocess import shutil -import curses from datetime import datetime -from colorama import Fore from os.path import expanduser # Some initial variables @@ -61,6 +59,26 @@ for word in confArgList: mashPath[pathStrIndex] = mashPath[pathStrIndex] + letter except Exception: mashPath.append(letter) + if word == "colour:": + colourConf = confArgList[confArgList.index(word) + 1] + colourList = [""] + colourListIndex = 0 + for letter in colourConf: + if letter == ";": + colourListIndex = colourListIndex + 1 + colourList.append("") + else: + colourList[colourListIndex] = colourList[colourListIndex] + letter + colourCodes = [] + for word in colourList: + if word == 'white': + colourCodes.append('\033[97m') + elif word == 'blue': + colourCodes.append('\033[34m') + elif word == 'green': + colourCodes.append('\033[32m') + elif word == 'yellow': + colourCodes.append('\033[33m') # Write the time to the history file historyFile = open((expanduser("~") + "/.history.mash"), "a") historyFile.write("\n") @@ -79,7 +97,7 @@ def mainLoop(startDir): while True: # Set directory and prompt for input. os.chdir(currentDirectory) - command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ") + command = input(colourCodes[0] + user + colourCodes[1] + "@" + colourCodes[2] + socket.gethostname() + colourCodes[3] + " " + currentDirectory + colourCodes[4] + " > ") if command == "" : mainLoop(currentDirectory) # Clean some things up for the argument parser. @@ -178,4 +196,4 @@ def mainLoop(startDir): except KeyboardInterrupt: print("\n") mainLoop(currentDirectory) -mainLoop(initDirectory) +mainLoop(initDirectory) \ No newline at end of file