How do I "replay" the "Caveats" section from a homebrew recipe

When installing a homebrew recipe, you occasionally will get some useful information in the "Caveats" section that you may want to tuck under your hat. Is there any way to replay or access this information once it has been displayed at install or is it lost forever unless you copy paste somewhere?

e.g.

==> Caveats
To have launchd start mongodb at login:
    ln -s /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/
Then to load mongodb now:
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
    mongod

I might want to be able to see this again and/or know where that plist is if I want it later.

tl;dr How do I see the above snippet again after I've installed something from homebrew?


Solution 1:

brew info mongodb will display it. If you make the changes suggested by the Caveats however, there may be other Caveats presented which will be more applicable to your actual situation.

Solution 2:

I created a brew external command for that: https://github.com/rafaelgarrido/homebrew-caveats

$ brew caveats zsh
==> zsh: Caveats
Add the following to your zshrc to access the online help:
    unalias run-help
    autoload run-help
    HELPDIR=/usr/local/share/zsh/helpfiles

You can also pass multiple formulas:

$ brew caveats rabbitmq mongodb
==> rabbitmq: Caveats
Management Plugin enabled by default at http://localhost:15672

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

To have launchd start rabbitmq at login:
  ln -sfv /usr/local/opt/rabbitmq/*.plist ~/Library/LaunchAgents
Then to load rabbitmq now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
Or, if you don't want/need launchctl, you can just run:
  rabbitmq-server

==> mongodb: Caveats
To have launchd start mongodb at login:
  ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
  mongod --config /usr/local/etc/mongod.conf

Pretty handy when you need to check some configs!

Solution 3:

To see all caveats of the currently installed formulas you can use the following command

brew info $(brew list)

You can also filter the output with awk to only get the caveats sections. (I am an awk newbie suggestions or edits are welcome)

brew info $(brew list) | awk '/^==> Caveats$/,/^[a-z][a-zA-Z0-9_+-]+: stable |^==> (Dependencies|Options)$/'

Solution 4:

Another possibility is to use sed

brew info $(brew list) | sed '/==> Caveats/,/==>/!d;//d'

And to have a formatted output (bash)

for cmd in $(brew list); do 
  if brew info $cmd | grep -q Caveats; then
    echo "$cmd\n"; 
    brew info $cmd | sed '/==> Caveats/,/==>/!d;//d'; 
    printf '%40s\n' | tr ' ' -; 
  fi; 
done;