From be6f7cf8993a07cc085488cebd22ec05707778f7 Mon Sep 17 00:00:00 2001 From: Ignace Mouzannar Date: Sat, 23 Nov 2024 22:51:57 -0500 Subject: [PATCH] Add prompt color support using ANSI codes (Closes: #18) (#252) --- etc/lshell.conf | 7 +++++-- lshell/checkconfig.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/etc/lshell.conf b/etc/lshell.conf index 237aed0..2407f09 100644 --- a/etc/lshell.conf +++ b/etc/lshell.conf @@ -13,7 +13,7 @@ loglevel : 2 #logfilename : syslog ## in case you are using syslog, you can choose your logname -#syslogname : myapp +#syslogname : lshell ## Set path to sudo noexec library. This path is usually autodetected, only ## set this variable to use alternate path. If set and the shared object is @@ -76,7 +76,10 @@ aliases : {'ll':'ls -l'} #intro : "== My personal intro ==\nWelcome to lshell\nType '?' or 'help' to get the list of allowed commands" ## configure your prompt using %u or %h (default: username) -#prompt : "%u@%h" +# prompt : "%u@%h" +## colored prompt using ANSI escape codes colors (light red user, light cyan host) +prompt : "\033[91m%u\033[97m@\033[96m%h\033[0m" + ## set sort prompt current directory update (default: 0) #prompt_short : 0 diff --git a/lshell/checkconfig.py b/lshell/checkconfig.py index 2734957..3412c94 100644 --- a/lshell/checkconfig.py +++ b/lshell/checkconfig.py @@ -133,7 +133,7 @@ def check_config_file(self, file): self.stderr.write("Error: Config file doesn't exist\n") utils.usage() else: - self.config = configparser.ConfigParser() + self.config = configparser.ConfigParser(interpolation=None) def get_global(self): """Loads the [global] parameters from the configuration file""" @@ -307,7 +307,7 @@ def get_config_sub(self, section): conf.append((key, self.conf[key])) if self.config.has_section(section): - conf = self.config.items(section) + conf + conf = list(self.config.items(section)) + conf for item in conf: key = item[0] value = item[1]