Browse Source

colorize: add $PAGER support

Signed-off-by: Alejandro Mery <amery@geeks.cl>
master
Alejandro Mery 11 years ago
parent
commit
559bd84e13
1 changed files with 13 additions and 1 deletions
  1. +13
    -1
      files/bin/colorize

+ 13
- 1
files/bin/colorize

@ -10,6 +10,18 @@ if [ $# -eq 0 ]; then
set -- "$tmp_f"
fi
if [ -t 1 ]; then
if env | grep -q ^PAGER=; then
if [ -z "$PAGER" ]; then
PAGER=cat
fi
else
PAGER="less -R"
fi
else
PAGER=cat
fi
for f; do
l=
eval t=$(file -i - < "$f" | cut -d' ' -f2-)
@ -23,7 +35,7 @@ for f; do
esac
pygmentize ${l:+-l $l} "$f"
done
done | $PAGER
if [ -n "$tmp_f" ]; then
rm -f "$tmp_f"

Loading…
Cancel
Save