Last active
June 3, 2022 02:54
-
-
Save fish2000/1bfbfbcdedbb3ee668359e3f17bf32d4 to your computer and use it in GitHub Desktop.
Homebrew external-command script to show syntax-highlited formulae, using Pygments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #: * `show` <formula> [<formula>...]: | |
| #: Show the syntax-highlighted source of the specified formulae | |
| function brew() { | |
| "${HOMEBREW_PREFIX}/bin/brew" "$@" | |
| } | |
| pygmentize="$(which pygmentize)" | |
| if [[ ! -x $pygmentize ]]; then | |
| echo "* ERROR: The “pygmentize” command was not found" | |
| echo "* ERROR: Try installing the Python “pygments” package" | |
| return 1 | |
| else | |
| for argument in "$@"; do | |
| brew cat "${argument}" | "${pygmentize}" -l ruby | |
| echo "" | |
| done | |
| fi |
Author
Author
- Supports multiple formula-name arguments (versus e.g. the
brew catcommand)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
brew-show(without the “.sh”), and copying it to a directory somewhere included in your $PATHbrew show <formula>e.g.brew show cmake