66

安装自制配方时,您有时会在“注意事项”部分中获得一些有用的信息,您可能想把它们藏在帽子里。一旦在安装时显示此信息,是否有任何方法可以重播或访问此信息,或者除非您在某处复制粘贴,否则它会永远丢失?

例如

==> 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从自制软件安装某些内容后,如何再次看到上述代码段?

4

6 回答 6

84

brew info mongodb将显示它。但是,如果您做出警告建议的更改,可能会出现其他更适用于您的实际情况的警告。

于 2012-11-11T18:03:05.487 回答
17

我为此创建了一个 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

当您需要检查一些配置时非常方便!

于 2015-05-22T06:42:06.563 回答
10

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

brew info $(brew list)

您还可以使用 awk 过滤输出以仅获取警告部分。(我是 awk 新手,欢迎提出建议或编辑)

brew info $(brew list) | awk '/^==> Caveats$/,/^[a-z][a-zA-Z0-9_+-]+: stable |^==> (Dependencies|Options)$/'
于 2013-10-02T13:43:15.153 回答
5

另一种可能性是使用 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;
于 2016-05-25T18:46:54.557 回答
0

对于那些拥有很棒的jq工具的人:

# For brews
$ brew info --json $(brew list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'

# For casks
$ brew cask --json=v1 info $(brew cask list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'

jq是一个命令行 JSON 处理器。

于 2020-05-26T13:03:35.557 回答
0

更新和组合上面的几个答案,这是一个 bash/zsh 循环,可以粘贴到终端中,以获取所有已安装 brew 公式的所有警告。

for x in $(brew list --formula); do 
    cavs=$(brew info "$x" | sed '/==> Caveats/,/==>/!d;//d')
    if [ ! -z "$cavs" ]; then
        echo "$x"
        echo "---"
        echo "$cavs"
        echo ""
    fi
done
于 2021-01-27T05:08:36.233 回答