gpt4 book ai didi

imagemagick - 我可以只链接没有冲突的文件吗?

转载 作者:行者123 更新时间:2023-12-05 07:40:12 24 4
gpt4 key购买 nike

有没有办法只brew link那些没有冲突的文件?

据我所知,唯一的选择是强制覆盖所有冲突的角色,或者根本不链接任何文件。例如,我有一个现有的 compare 需要保留,但需要 ImageMagick 的 convert。当我 brew install imagemagick 我得到

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/compare
Target /usr/local/bin/compare
already exists. You may want to remove it:
rm '/usr/local/bin/compare'

To force the link and overwrite all conflicting files:
brew link --overwrite imagemagick

To list all files that would be deleted:
brew link --overwrite --dry-run imagemagick

Possible conflicting files are:
/usr/local/bin/compare -> /Applications/Araxis Merge.app/Contents/Utilities/compare

但提供的唯一继续进行的方法是不链接所有 ImageMagick,或者覆盖我现有的compare

除了现有的比较之外,我如何brew link所有内容?有没有办法只安装 convert

最佳答案

这是我为执行此操作而编写的一个 shell 函数(针对 zsh,它现在是 macOS 的标准配置,但只需稍作调整 1 即可在 Bash 上运行):

local targetdir
targetdir=($(brew --cellar $1)/*/bin) || return
local linksdir=$(brew --repo)/bin

for ex in "$targetdir"/*(^/) # files (and symlinks), not subdirectories
do
local exname=${ex##*/}
if builtin which "$exname" &>/dev/null
then
echo " $exname already available in the path - skipped"
else
ln -s "$ex" "$linksdir/" && echo "$exname linked from $linksdir"
fi
done

我将其保存为 shell function称为 blink,当我用包名调用它时,比如

blink binutils

它仅对名称在 $PATH 中不可用的二进制文件进行符号链接(symbolic link)。

1使它在 Bash 上工作的调整:删除最后的 (^/) 形式的 for ex... 行,builtin 3 行再往下。

关于imagemagick - 我可以只链接没有冲突的文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46391301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com