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
  • Assumed you missed a word; revert the edit if I'm wrong.
    – Jeff Schaller
    Aug 17, 2017 at 16:56
  • @JeffSchaller thanks for the edit I don't remember, but probably wanted to add line after the code.
    – jcubic
    Aug 17, 2017 at 18:10

3 Answers 3


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:

          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).

  • 2
    This don't change behavior of msgattrib that will not produce the colors if you pipe to less, -R will not change anything because there will be no escapes codes.
    – jcubic
    Mar 3, 2020 at 20:57
  • @jcubic's comment here is correct, but this answer does provide that you won't need the -r or -R flag when piping output from unbuffer as in @jcubic's answer.
    – mc0e
    Sep 3, 2023 at 5: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

  • This just duplication of accepted and upvoted answer. Add answer only if yours is not already added.
    – jcubic
    Jun 10, 2019 at 10:16
  • this is how to config it as always (with alias) Jun 11, 2019 at 12:27
  • This is not question about aliases. Only about less and it's already answered with same code as your answer.
    – jcubic
    Jun 11, 2019 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .