From c8c7a5137473770eb4b2d9d54495c2a39b32cbe3 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Fri, 1 Mar 2013 14:27:40 -0500 Subject: add a config settings and flag for colours Colours can be enabled in two ways: - Add Color to pacman.conf. This enables colours automatically. - Use --color=WHEN where WHEN is none/auto/always. WHEN as 'never' disables colours (overrides config file), as 'auto' enables colours when stdout is a tty, and 'always' enables colours no matter what. Signed-off-by: Simon Gomizelj Signed-off-by: Allan McRae --- src/pacman/conf.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/pacman/conf.c') diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 218ffb46..dca6e3e1 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -436,6 +436,10 @@ static int _parse_options(const char *key, char *value, pm_printf(ALPM_LOG_DEBUG, "config: totaldownload\n"); } else if(strcmp(key, "CheckSpace") == 0) { config->checkspace = 1; + } else if(strcmp(key, "Color") == 0) { + if(config->color == PM_COLOR_UNSET) { + config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF; + } } else { pm_printf(ALPM_LOG_WARNING, _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), -- cgit v1.2.3