89 homebrew
我正在寻找一种方法来只显示我安装的公式而没有安装的依赖项.我希望有一个我实际安装的所有程序的列表,没有依赖项的所有噪音.
我知道brew list哪些列表都安装了公式.我也知道这brew graph给了我一个依赖图graphviz
或者换句话说:我希望有一套最小的公式来重新安装我的系统.
Den*_*hev 154
使用brew leaves:显示不是另一个已安装公式的依赖项的已安装公式.
Adr*_*rth 21
$ brew deps --installed
tmux: pkg-config libevent
q:
gdbm:
libxml2:
asciidoc: docbook
libevent:
pkg-config:
pcre:
docbook:
zsh: gdbm pcre
readline:
emacs: pkg-config
Run Code Online (Sandbox Code Playgroud)
这似乎为我们提供了所有已安装公式的列表,包括它们的依赖项.我们可以构建所有公式的列表和所有依赖项的列表,并从公式列表中减去依赖项,这应该给我们一个公式列表,这些公式不是其他公式的依赖项:
$ cat brew-root-formulae.sh
#!/bin/sh
brew deps --installed | \
awk -F'[: ]+' \
'{
packages[$1]++
for (i = 2; i <= NF; i++)
dependencies[$i]++
}
END {
for (package in packages)
if (!(package in dependencies))
print package
}'
Run Code Online (Sandbox Code Playgroud)
.
$ ./brew-root-formulae.sh
zsh
asciidoc
libxml2
readline
tmux
q
emacs
Run Code Online (Sandbox Code Playgroud)
这是你追求的输出吗?
小智 14
这个问题很老了,但实际上只有这个答案才能解决问题。然而,它更像是一种解决方法。但还有另一种现成可用的解决方案brew:
brew bundle dump --file -
Run Code Online (Sandbox Code Playgroud)
来自文档:
brew bundle dump:
Write all installed casks/formulae/images/taps into a Brewfile in the
current directory.
Run Code Online (Sandbox Code Playgroud)
和旗帜:
--file
Read the Brewfile from this location.
Use --file=- to pipe to stdin/stdout.
Run Code Online (Sandbox Code Playgroud)
结果我们得到例如:
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
tap "jesseduffield/lazydocker"
tap "jesseduffield/lazygit"
brew "lazydocker"
brew "lazygit"
cask "font-sauce-code-pro-nerd-font"
Run Code Online (Sandbox Code Playgroud)
例如,如果您需要一个纯粹的配方和木桶列表,无需水龙头,您只需运行:
brew bundle dump --file - | grep '^brew\|^cask' | sed 's/.* "\(.*\)".*$/\1/'
Run Code Online (Sandbox Code Playgroud)
并得到:
lazydocker
lazygit
font-sauce-code-pro-nerd-font
Run Code Online (Sandbox Code Playgroud)
PS 如果您实际上将输出保存到文件中(使用brew bundle dump或brew bundle dump --file PATH_TO_FILE),则可以使用以下命令轻松安装其中的所有依赖项brew bundle install:
brew bundle [install]:
Install and upgrade (by default) all dependencies from the Brewfile.
You can specify the Brewfile location using --file or by setting the
HOMEBREW_BUNDLE_FILE environment variable.
Run Code Online (Sandbox Code Playgroud)
这将安装的公式显示为树。
brew deps --installed --tree
Run Code Online (Sandbox Code Playgroud)
只显示下一层的依赖关系
brew deps --1 --installed --tree
Run Code Online (Sandbox Code Playgroud)
只显示已安装的 php 公式
brew deps --installed --tree php
Run Code Online (Sandbox Code Playgroud)
打开一个网站进行可视化
brew deps --installed --graph php
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12934 次 |
| 最近记录: |