Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different font style / color for stderr #954

Open
mkq opened this issue Jan 11, 2020 · 4 comments
Open

different font style / color for stderr #954

mkq opened this issue Jan 11, 2020 · 4 comments

Comments

@mkq
Copy link

mkq commented Jan 11, 2020

I'm not sure whether it's even possible (and the terminal's business), but it would be cool to have a different font style and / or color for output written to standard error. (Workarounds I have found are for other OSes or wrappers you have to invoke around the actual command.)

Configuration could be:

  • a string of escape sequences
  • a boolean whether the style should only be applied to default-style text (though it seems to be very uncommon for an application to print styled text to stderr, just to be on the safe side).

Thanks!

@GeekDuanLian
Copy link
Contributor

This can be achieved through bash itself, see https://serverfault.com/questions/59262/bash-print-stderr-in-red-color/570651#570651

@mkq
Copy link
Author

mkq commented Jan 11, 2020

Thanks, I had already skimmed through that page before creating this issue. While this solution is a great improvement over the wrappers you have to explicitely invoke, it's still a wrapper with some caveats (see comments). I haven't tried, but "This does not work on Cygwin" in particular would a real problem.

Also, from what I did try, it has a major performance penalty. The following command took 9 seconds on my computer:

for ((i=0;i<1000000;i++)); do echo $i; done

And this, adding the read loop from that answer, took 373 seconds:

for ((i=0;i<1000000;i++)); do echo $i; done | while IFS='' read -r line || [ -n "$line" ]; do echo -e "\033[31m${line}\033[0m"; done

So, while I might try that solution if need be, for now it rather supports my impression that this feature would better be handled by the terminal.

BTW, I'm using zsh. But the solution sounds like it could be easily adapted to zsh.

@mintty
Copy link
Owner

mintty commented Jan 12, 2020

This is a neat idea and maybe a more efficient wrapping method can be found. On the other hand, as stdout and stderr might interweave even by character, to be on the safe side, probably every single character would need to be wrapped...
Anyway, when output finally arrives at the terminal, its path through stdout or stderr cannot be distinguished as these are internal operating system concepts. So there is not much, not to say nothing, that the terminal could do about it.

@mkq
Copy link
Author

mkq commented Jan 12, 2020

OK, thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants