You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
355 B

  1. #!/bin/sh
  2. exec 2>&1
  3. tmp_f=
  4. if [ $# -eq 0 ]; then
  5. tmp_f="${TMPDIR:-/tmp}/colorize.$$"
  6. cat > "$tmp_f"
  7. set -- "$tmp_f"
  8. fi
  9. for f; do
  10. l=
  11. eval t=$(file -i - < "$f" | cut -d' ' -f2-)
  12. case "$t" in
  13. application/xml)
  14. l=xml
  15. ;;
  16. text/x-shellscript)
  17. l=sh
  18. ;;
  19. esac
  20. pygmentize ${l:+-l $l} "$f"
  21. done
  22. if [ -n "$tmp_f" ]; then
  23. rm -f "$tmp_f"
  24. fi