Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Last active January 28, 2023 22:40
Show Gist options
  • Save mttjohnson/c1d5e52d1b900d764711b32e5702c9f1 to your computer and use it in GitHub Desktop.
Save mttjohnson/c1d5e52d1b900d764711b32e5702c9f1 to your computer and use it in GitHub Desktop.
Colorize code files on shell
# Install Pygments (https://pygments.org/)
pip install Pygments
brew install pygments
# XML
cat myfile.xml | xmllint --format - | pygmentize -l xml
# JSON
cat myfile.json | jq . | pygmentize -l json
# YAML
cat myfile.yml | yq e '.' - | pygmentize -l yaml
# PHP
cat myfile.php | pygmentize -l php
# Markdown
cat myfile.md | pygmentize -l markdown
# JS
cat myfile.js | pygmentize -l js
# CSS
cat critical.css | pygmentize -l css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment