Add colour config compatibility
This commit is contained in:
parent
b7d080d4aa
commit
c4b0d5e950
24
main.py
24
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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user