如何从“自制食谱”“重复”“注意”部分?

在安装自制食谱时,偶尔会在“警告”一节中获得一些有用的信息,您可能需要在帽子下面掖着。 有没有什么方法可以重放或访问这些信息,一旦它被安装显示,或者它永远丢失,除非你复制粘贴到某个地方?

例如

==> 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 

我可能希望能够再次看到这个和/或知道如果我以后需要plist的话。

tl; dr我从自制软件安装了一些东西后,如何再次看到上面的代码片段?

brew info mongodb会显示它。 但是,如果您进行警告所提示的更改,则可能会提供其他警告,这些警告将更适合您的实际情况。

我为此创build了一个brew外部命令: 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 

您也可以传递多个公式:

 $ 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 

当你需要检查一些configuration时,非常方便!

要查看当前安装的公式的所有注意事项,可以使用以下命令

 brew info $(brew list) 

您也可以使用awk过滤输出以仅获取警告部分。 (我是一个awk新手build议或编辑是受欢迎的)

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

另一种可能是使用sed

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

并有一个格式化的输出(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;