Colour Linux Error Output Red

Best ZSH Linux Terminal gimmick

Colored std-err output

Compiling

Clone the repository. The project is quite old, so any modern system with gcc should be able to compile and run it. It doesn’t have any additional dependencies. Built it with:

Setup

Now we need to tell our shell how to use this library. As stated in the beginning, I’m using z-shell, so I’m editing ~/.zshrc. We first need to set the LD_PRELOAD variable to the absolute path of our library, then tell the library which file-descriptor(s) to color, via a variable called COLORRED_STDERR_FDS(this expects a list, so mind the comma at the end of the line, if you are only using one value) and finally export both of those variables.

Basic libcolorstderr configuration
Fix ZSH by re-exec’ing it

Problems

Using this approach rarely causes issues, but I found a few notable programs which do not start with the library preloaded. Those are the signal-client (based on electron) and chromium. Also starting other shells from the colored z-shell may cause issues with the coloring in the sub-shells (e.g. starting ZSH from ZSH is not a problem but starting bash from ZSH is). You may define aliases to unset LD_PRELOAD, before starting these applications and keep this in mind, if anything similar (for example another electron application) doesn’t work.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yannik Schmidt

Python programmer at heart, Linux Expert at work, GameDev on my good days, web developer on the bad days.