On Fri, 30 Jun 2023 14:46:38 +0100
Barry Scott <barry(a)barrys-emacs.org> wrote:
> On 30 Jun 2023, at 14:15, stan via users
> <users(a)lists.fedoraproject.org> wrote:
> This is correct. After I posted this, I found that it is
> impossible to actually set the colors in journalctl because they
> are hard coded as escape sequences when the data is written into
> the journal. What I had done is remove the R option to less, which
> turns off such escape sequences. In my case, the less options I
> set for color then seems to highlight the ESC in light red, so I
> know which lines journalctl wants to highlight, but not their
> status. That isn't optimal, but the horrible dark blue on black
> background is gone, so I can live with it.
I would be nice to be able to configure the colours used. Would need
a PR against systemd I expect to get this changed.
One hack would be to edit the output and replace the escape sequence
for the poor colour to use a replacement using sed I guess.
For example change the blue to red.
SYSTEMD_COLORS=16 journalctl | sed 's/\x1b\[0;34m/\x1b\[0;31m/g' |
more
I use more not less and notice that less does not show the coloured
output.
Barry
Thanks, this worked for me with both more and less, and the red is much
more palatable. I think the default for less is not to have --use-color
set, so that is probably why it didn't work for you. I set it on login.
This could be put as a function in .bashrc so that invoking something
like jrctl would run it automatically. I'm not sure how that would
work for the OP who wanted to use cat though.
I tried
$ SYSTEMD_COLORS=16 journalctl -r | sed 's/\x1b\[0;34m/\x1b\[0;31m/g' | cat -
and it worked to send the output colored correctly to stdout, but there
was no paging, it just was a continuous stream.