Skip to content

Instantly share code, notes, and snippets.

@fish2000
Last active June 3, 2022 02:54
Show Gist options
  • Select an option

  • Save fish2000/1bfbfbcdedbb3ee668359e3f17bf32d4 to your computer and use it in GitHub Desktop.

Select an option

Save fish2000/1bfbfbcdedbb3ee668359e3f17bf32d4 to your computer and use it in GitHub Desktop.
Homebrew external-command script to show syntax-highlited formulae, using Pygments
#!/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
@fish2000

fish2000 commented Nov 16, 2018

Copy link
Copy Markdown
Author
  • Install this by renaming it brew-show (without the “.sh”), and copying it to a directory somewhere included in your $PATH
  • Invoke with brew show <formula> e.g. brew show cmake

@fish2000

Copy link
Copy Markdown
Author
  • Supports multiple formula-name arguments (versus e.g. the brew cat command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment