I was looking for a way to color stderr so when I ran
:!make target, I'd see the stderr lines pop up in red so I could more easily see what stopped my build.
Inspired by this answer: https://serverfault.com/a/59279, I made the following file:
exec 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done)
Then I'd run vim via:
When I'd do
:!make target-with-error, the stderr text now shows up as red. Everything looks right to me.
I was wondering if there's a better way to color stderr. I'm mostly interested in avoiding some "gotchas" that I haven't thought of with using the exec command in this manner. Thanks.
For those who tried this and like the effect, add
let $BASH_ENV=~/.vim/vim_bash to your .vimrc or .vim/vimrc file.