在很长一段时间里,我无法让 justfile 的
just
命令自动完成。我终于找到了让just
工作的方法。但是,由于 Homebrew,它似乎破坏了我的 git 别名自动完成功能。
示例:
这是一个可以让一切正常运行的解决方案。将以下内容添加到您的
.zshrc
:
# ------ Homebrew ZSH functions (for just + others)
# This will bring autocomplete for brew installed functions (exa, just, k6, etc)
# These will overwrite the oh-my-zsh plugins that conflict (like `git`)
# https://github.com/casey/just#shell-completion-scripts
# Init Homebrew, which adds environment variables
eval "$(brew shellenv)"
remove_conflicting_git_completions() {
local git_completion_bash="$HOMEBREW_PREFIX/share/zsh/site-functions/git-completion.bash"
local git_completion_zsh="$HOMEBREW_PREFIX/share/zsh/site-functions/_git"
[ -e "$git_completion_bash" ] && rm "$git_completion_bash"
[ -e "$git_completion_zsh" ] && rm "$git_completion_zsh"
}
# Delete the brew version of `git` completions because the built in ZSH
# ones are objectively better (and work with aliases)
# The reason this runs every time is because brew re-adds these files
# on `brew upgrade` (and other events)
remove_conflicting_git_completions
# Add Homebrew's site functions to fpath (minus git, because that causes conflicts)
# https://github.com/orgs/Homebrew/discussions/2797
# https://github.com/ohmyzsh/ohmyzsh/issues/8037
# https://github.com/ohmyzsh/ohmyzsh/issues/7062
fpath=($HOMEBREW_PREFIX/share/zsh/site-functions $fpath)
# Needed for autosuggestions (does compinit)
source $ZSH/oh-my-zsh.sh
如果您想了解更多有关brew的git功能(或其他可行的解决方案)的其他更糟糕的内容,请检查以下链接: