46

我正在使用 oh-my-zsh,每次打开终端时都会出现此错误:

WARNING: this script is deprecated, please see git-completion.zsh

有什么解决办法吗?

4

4 回答 4

33

可能看起来很傻,但请确保您~/.zshrc获取文件的来源(如果文件不存在,请创建一个)。在 OSX 上,我完全忘记了我已经切换到 zsh,并得到了你提到的错误,因为我正在做source ~/.bashrc

  1. 让自动完成工作的最简单方法是通过Homebrew安装它(它适用于 zsh 和 bash。):
brew install bash-completion
  1. 把它放进你的~/.zshrc
# auto-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
  . /opt/local/etc/profile.d/bash_completion.sh
fi
  1. 保存文件并做一个source ~/.zshrc,你会很好
于 2017-01-20T16:00:43.027 回答
3

对我来说,我只是在迁移到 zsh 时复制了~/.bash_profileto的内容。~/.zprofile我只是删除了这一行,这是警告消息的根本原因:

source ~/.profile

于 2019-06-05T23:38:06.683 回答
0

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)
于 2021-09-30T16:42:55.993 回答
-1

在控制台中输入:

curl https://github.com/git/git/raw/master/contrib/completion/git-completion.zsh -OL

将此添加到您的.profile/ .bashrc/之一中.zshrc

source ~/git-completion.zsh

于 2014-07-14T17:25:20.250 回答