When I use:
msgattrib --untranslated pl.po
to see untranslated strings from po file I've got strings in color, but not when I use:
msgattrib --untranslated pl.po | less
When I use:
msgattrib --untranslated pl.po
to see untranslated strings from po file I've got strings in color, but not when I use:
msgattrib --untranslated pl.po | less
msgattrib
display colors only if executed from real terminal. You can use unbuffer
command that's part of expect
to make msgattrib
think that it's executed from real terminal and then use -r
option to handle ANSI escapes in less
:
unbuffer msgattrib --untranslated pl.po | less -r
You can do that in any command that produce colors (ANSI escapes codes) based on existance of tty.
From the less man page:
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screen appearance is maintained correctly in most cases.
The simplest way to have this enabled all the time is to set the LESS
environment variable in your .profile
or .login
script. I use both -R
and -X
(which prevents the screen being cleared when less exits).
-r
or -R
flag when piping output from unbuffer
as in @jcubic's answer.
– mc0e
Sep 03 '23 at 05:17
To show less with colors: less -R <text-file>
Or config your less as an alias like alias less='less -R'
inside the ~/.bashrc