[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.11.5 Customizing less
for viewing PO files
The ‘less’ program is a popular text file browser for use in a text screen or terminal emulator. It also supports text with embedded escape sequences for colors and text decorations.
You can use less
to view a PO file like this (assuming an UTF-8
environment):
msgcat --to-code=UTF-8 --color xyz.po | less -R
You can simplify this to this simple command:
less xyz.po
after these three preparations:
-
Add the options ‘-R’ and ‘-f’ to the
LESS
environment variable. In sh shells:$ LESS="$LESS -R -f" $ export LESS
-
If your system does not already have the ‘lessopen.sh’ and
‘lessclose.sh’ scripts, create them and set the
LESSOPEN
andLESSCLOSE
environment variables, as indicated in the manual page (‘man less’). -
Add to ‘lessopen.sh’ a piece of script that recognizes PO files
through their file extension and invokes
msgcat
on them, producing a temporary file. Like this:case "$1" in *.po) tmpfile=`mktemp "${TMPDIR-/tmp}/less.XXXXXX"` msgcat --to-code=UTF-8 --color "$1" > "$tmpfile" echo "$tmpfile" exit 0 ;; esac
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on June 7, 2014 using texi2html 5.0.