Homebrew fortune
doesn't include the full database of quotes. They removed the offensive category database several years ago:
You are greeted with an error when trying to use the offensive category:
❯ brew install fortune
❯ fortune -o
/opt/homebrew/Cellar/fortune/9708/share/games/fortunes/off: No such file or directory
Whether or not I will use the offensive quotes is irrelevant for me, personally. I'd just like the choice, without going through another package manager or hosting my own tap. This is the solution I've come up with.
Generally, one can brew install https://raw.githubusercontent.com/...
to install a specific formula version. But there have been many changes in the years since the offensive category was removed - notably a file rename and support for new architecture. Using a prior formula version may or may not work depending on your computer, and is not very future-proof.
Warning
They are labeled offensive for a reason...
Instead we can download the latest formula definition and modify it to include the full database, and then pass that to brew install
. Luckily, all that's required is the removal of the one line that references the OFFENSIVE
make variable:
# This is the URL we want
❯ brew info fortune | awk '/From: / {print $2}'
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/f/fortune.rb
# Download and delete the OFFENSIVE line
❯ brew info fortune \
| awk '/From: / {print $2}' \
| curl -sSL \
--variable url@- \
--expand-url '{{url:trim}}?raw=true' \
| sed '/OFFENSIVE/d' \
> /tmp/fortune.rb
# (Re)install our modified formula from source
❯ brew reinstall --formula --force --build-from-source /tmp/fortune.rb
# Check that it worked
❯ fortune -o
Ass, grass or gas... nobody rides for free!
# Pin our version to prevent unintentional future upgrades
❯ brew pin fortune
See: offensive content removal
❯ brew info cowsay | awk '/From: / {print $2}'
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c/cowsay.rb
# Download and delete the offensive lines
❯ brew info cowsay \
| awk '/From: / {print $2}' \
| curl -sSL \
--variable url@- \
--expand-url '{{url:trim}}?raw=true' \
| sed '/offensive/,/end/d' \
> /tmp/cowsay.rb
# (Re)install our modified formula from source
❯ brew reinstall --formula --force --build-from-source /tmp/cowsay.rb
# Check that it worked
❯ cowsay -l
# Pin our version to prevent unintentional future upgrades
❯ brew pin cowsay