Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to format the zsh output.

eg for unfound functions I now have:

function command_not_found_handler(){echo $fg[red]"\033[4m???\033[0m"$fg[red]" Command \"$1\" not found."}

which returns red text and underlined ???.

I did this for the command_not_found_handler and would like to apply the same logic to other error output e.g.:

zsh: bad pattern: echo[


zsh: correct 'ehco' to 'echo' [nyae]?

yet I can't seem to find the names of the correct handlers. Do they even exist as handlers? If not is there a more general approach to changing the warning/error/info output in zsh?

A more general approach would be nice so that errors from other programs would also ge the same format. e.g.

cd: no such file or directory: no/dir

perhaps modify standard error output (I don't know if this even makes sense, I'm really tired...)

share|improve this question
up vote 0 down vote accepted

Ok I found out myself.

Using the c script here, and modifying it a bit, I got what I needed.

The modifying that took part was this: because I wanted the underlined ??? in front of each error, I changed the loop at line 107 to print ??? before looping over the rest of the error. This was down like so:

 if (buffer[0] == 27)
     dontcol = 1;
 if (buffer[0] == '\n')
     dontcol = 0;
 if (!dontcol)
     fputs(begstr, stdout);
     fputs("\0033[4m??? \033[0m", stdout);     
 if (!dontcol)
     fputs(endstr, stdout);
for (i = 1; i < n; i++)
              if (buffer[i] == 27)
                dontcol = 1;
              if (buffer[i] == '\n')
                dontcol = 0;
              if (!dontcol)
                fputs(begstr, stdout);
              if (!dontcol)
                fputs(endstr, stdout);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.