@@ -68,7 +68,7 @@ def _load_config(self) -> None:
6868
6969 def get_default_username (self ) -> Optional [str ]:
7070 """
71- Get the default GitHub username from config.
71+ Get the default username from config.
7272
7373 Returns:
7474 Default username or None if not set
@@ -83,14 +83,48 @@ def get_colors(self) -> dict:
8383 Returns:
8484 User defined colors or default colors if not set
8585 """
86- return self .config ._sections ["COLORS" ]
86+ # Color name to ANSI code mapping
87+ color_names = {
88+ 'black' : '\\ 033[30m' ,
89+ 'red' : '\\ 033[91m' ,
90+ 'green' : '\\ 033[92m' ,
91+ 'yellow' : '\\ 033[93m' ,
92+ 'blue' : '\\ 033[94m' ,
93+ 'magenta' : '\\ 033[95m' ,
94+ 'cyan' : '\\ 033[96m' ,
95+ 'white' : '\\ 033[97m' ,
96+ 'gray' : '\\ 033[90m' ,
97+ 'bright_red' : '\\ 033[91m' ,
98+ 'bright_green' : '\\ 033[92m' ,
99+ 'bright_yellow' : '\\ 033[93m' ,
100+ 'bright_blue' : '\\ 033[94m' ,
101+ 'bright_magenta' : '\\ 033[95m' ,
102+ 'bright_cyan' : '\\ 033[96m' ,
103+ 'bright_white' : '\\ 033[97m' ,
104+ 'orange' : '\\ 033[38;2;255;165;0m' ,
105+ 'purple' : '\\ 033[95m' , # alias for magenta
106+ 'pink' : '\\ 033[95m' , # alias for magenta
107+ }
108+
109+ colors = self .config ._sections ["COLORS" ]
110+ resolved_colors = {}
111+
112+ for key , value in colors .items ():
113+ # If the value is a known color name, map it to ANSI code
114+ if value .lower () in color_names :
115+ resolved_colors [key ] = color_names [value .lower ()]
116+ else :
117+ # Assume it's already an ANSI code or keep as-is
118+ resolved_colors [key ] = value
119+
120+ return resolved_colors
87121
88122 def set_default_username (self , username : str ) -> None :
89123 """
90- Set the default GitHub username in config.
124+ Set the default username in config.
91125
92126 Args:
93- username: GitHub username to set as default
127+ username: Username to set as default
94128 """
95129 if 'DEFAULT' not in self .config :
96130 self .config ['DEFAULT' ] = {}
@@ -203,7 +237,11 @@ def save(self) -> None:
203237
204238 if 'COLORS' in self .config :
205239 f .write ("[COLORS]\n " )
206- for key , value in self .config ['COLORS' ].items ():
207- f .write (f"{ key } = { value } \n " )
240+ # Find the longest key for alignment
241+ if self .config ['COLORS' ]:
242+ keys = list (self .config ['COLORS' ].keys ())
243+ max_key_length = max (len (key ) for key in keys )
244+ for key , value in self .config ['COLORS' ].items ():
245+ f .write (f"{ key :<{max_key_length }} = { value } \n " )
208246 f .write ("\n " )
209247 f .write ("\n " )
0 commit comments