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 '17 at 16:56
  • @JeffSchaller thanks for the edit I don't remember, but probably wanted to add line after the code. – jcubic Aug 17 '17 at 18:10

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


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 at 10:16
  • this is how to config it as always (with alias) – Yakir GIladi Edry Jun 11 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 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.