Browse Source

colorize: add new bin/ wrapping pygmentize + file

master
Alejandro Mery 11 years ago
parent
commit
145a3cc31a
1 changed files with 30 additions and 0 deletions
  1. +30
    -0
      files/bin/colorize

+ 30
- 0
files/bin/colorize

@ -0,0 +1,30 @@
#!/bin/sh
exec 2>&1
tmp_f=
if [ $# -eq 0 ]; then
tmp_f="${TMPDIR:-/tmp}/colorize.$$"
cat > "$tmp_f"
set -- "$tmp_f"
fi
for f; do
l=
eval t=$(file -i - < "$f" | cut -d' ' -f2-)
case "$t" in
application/xml)
l=xml
;;
text/x-shellscript)
l=sh
;;
esac
pygmentize ${l:+-l $l} "$f"
done
if [ -n "$tmp_f" ]; then
rm -f "$tmp_f"
fi

Loading…
Cancel
Save