Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Colors showing when TERM=dumb.



While playing around with my prompt I noticed that when TERM=dumb,
stuff like %B %U %S have no effect, but %F %K still print out terminal
escapes. Is this a bug? To work around it, I hacked putpromptchar in
prompt.c like this:

@@ -501,7 +501,7 @@
                        bv->fm--;
                } else
                    arg = match_colour(NULL, 1, arg);
-               if (arg >= 0 && !(arg & TXTNOFGCOLOUR)) {
+               if (arg >= 0 && !(arg & TXTNOFGCOLOUR) && tccan (TCFGCOLOUR)) {
                    txtchangeset(txtchangep, arg & TXT_ATTR_FG_ON_MASK,
                                 TXTNOFGCOLOUR);
                    txtset(arg & TXT_ATTR_FG_ON_MASK);
@@ -510,9 +510,11 @@
                }
                /* else FALLTHROUGH */
            case 'f':
+               if (tccan (TCFGCOLOUR)) {
                txtchangeset(txtchangep, TXTNOFGCOLOUR, TXT_ATTR_FG_ON_MASK);
                txtunset(TXT_ATTR_FG_ON_MASK);
                set_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, TSC_PROMPT);
+               }
                break;
            case 'K':
                if (bv->fm[1] == '{') {
@@ -522,7 +524,7 @@
                        bv->fm--;
                } else
                    arg = match_colour(NULL, 0, arg);
-               if (arg >= 0 && !(arg & TXTNOBGCOLOUR)) {
+               if (arg >= 0 && !(arg & TXTNOBGCOLOUR) && tccan (TCBGCOLOUR)) {
                    txtchangeset(txtchangep, arg & TXT_ATTR_BG_ON_MASK,
                                 TXTNOBGCOLOUR);
                    txtset(arg & TXT_ATTR_BG_ON_MASK);
@@ -531,9 +533,11 @@
                }
                /* else FALLTHROUGH */
            case 'k':
+               if (tccan (TCBGCOLOUR)) {
                txtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);
                txtunset(TXT_ATTR_BG_ON_MASK);
                set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, TSC_PROMPT);
+               }
                break;
            case '[':
                if (idigit(*++bv->fm))



Messages sorted by: Reverse Date, Date, Thread, Author