在安装自制软件时,您偶尔会在“警告”部分获得一些有用的信息,您可能希望将它们放在帽子下面。有没有什么方法可以在安装时显示重播或访问此信息,或者除非您在某处复制粘贴,否则它会永远丢失?
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
我可能希望能够再次看到这个并且/或者知道如果我以后想要它的位置。
tl; dr 在我安装自制软件后,如何再次看到上述代码?
答案 0 :(得分:64)
brew info mongodb
会显示它。但是,如果您进行了警告建议的更改,则可能会出现其他更适用于您实际情况的注意事项。
答案 1 :(得分:9)
我为此创建了一个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
当你需要检查一些配置时非常方便!
答案 2 :(得分:7)
要查看当前安装的公式的所有警告,您可以使用以下命令
brew info $(brew list)
您也可以使用awk过滤输出,只获取警告部分。 (我是一个awk新手建议或编辑是受欢迎的)
brew info $(brew list) | awk '/^==> Caveats$/,/^[a-z][a-zA-Z0-9_+-]+: stable |^==> (Dependencies|Options)$/'
答案 3 :(得分:1)
另一种可能性是使用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;
答案 4 :(得分: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处理器。
答案 5 :(得分: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