我正在使用 oh-my-zsh,每次打开终端时都会出现此错误:
WARNING: this script is deprecated, please see git-completion.zsh
有什么解决办法吗?
可能看起来很傻,但请确保您~/.zshrc
获取文件的来源(如果文件不存在,请创建一个)。在 OSX 上,我完全忘记了我已经切换到 zsh,并得到了你提到的错误,因为我正在做source ~/.bashrc
brew install bash-completion
~/.zshrc
:# auto-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
source ~/.zshrc
,你会很好对我来说,我只是在迁移到 zsh 时复制了~/.bash_profile
to的内容。~/.zprofile
我只是删除了这一行,这是警告消息的根本原因:
source ~/.profile
etc/profile.d/git-prompt.sh
在 Git for Windows 中,如果 shell 不是 Bash,则在执行文件期间发出此消息。
git-prompt.sh
来源git-completion.bash
而不查看外壳名称。该文件检查它是否不是由 Bash 运行的,发出警告消息并退出。
以下是相应代码的链接: https ://github.com/git/git/blob/master/contrib/completion/git-completion.bash#L3509
您应该查看位于该文件附近同一目录中的 git-completion.zsh 并按照开头注释中提供的安装说明进行操作:
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
在控制台中输入:
curl https://github.com/git/git/raw/master/contrib/completion/git-completion.zsh -OL
将此添加到您的.profile
/ .bashrc
/之一中.zshrc
:
source ~/git-completion.zsh