警告:不推荐使用此脚本,请参阅git-completion.zsh

zia*_*war 19 git zsh oh-my-zsh

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

WARNING: this script is deprecated, please see git-completion.zsh
Run Code Online (Sandbox Code Playgroud)

那有什么解决方案吗?

kuz*_*zyn 11

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

获得自动完成工作的最简单方法就是通过安装它家酿brew install bash-completion(它会为zsh的工作,以及bash)的,然后把这个到你~/.zshrc:

# auto-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
  . /opt/local/etc/profile.d/bash_completion.sh
fi
Run Code Online (Sandbox Code Playgroud)

保存文件并做一个source ~/.zshrc,你会很好

  • 对于这个问题,我的同事只需删除“.zshrc”文件中对 bash_completion 的引用即可。我们使用 ohmyzsh 并且自动完成功能已经实现。 (3认同)
  • 切换到zsh后,这为我解决了2个小时的麻烦。谢谢! (2认同)
  • 你节省了我很多时间。谢谢你!我刚刚切换到 macOS,你是唯一告诉我创建 `~/.zshrc` 的人 (2认同)
  • 它对我不起作用!:( (2认同)
  • @EzequielDeSimone 即使按照此答案的说明进行操作,我也必须在 zshrc 中注释掉“#source ~/git-completion.bash”以清除警告。也许这也有帮助。 (2认同)
  • 我能找到的最接近的文件是“/opt/homebrew/etc/bash_completion”。但是在 zsh 中获取它会出现很多错误,例如 `/opt/homebrew/etc/bash_completion:59: command not found: shopt` (2认同)

wl2*_*776 7

etc/profile.d/git-prompt.sh在 Windows 版 Git 中,如果 shell 不是 Bash,则在文件执行期间会发出此消息。

git-prompt.shgit-completion.bash无需查看 shell 名称即可获取来源。该文件检查它是否不是由 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)
Run Code Online (Sandbox Code Playgroud)


gdu*_*lle 6

在控制台中输入以下内容:

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

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

source ~/git-completion.zsh

  • 我从zsh中收到以下错误:zsh:12:找不到命令:___main(eval):1:找不到匹配项:*:所有文件_tags:comptags:36:只能从完成函数_tags:comptry调用: 55:只能从完成函数_tags:comptags:60调用:60只能从完成函数_tags:comptags:67调用:67只能从完成函数zsh --version zsh 5.0.5(x86_64-pc-linux- gnu)#我也使用Oh My Zsh。 (20认同)
  • `_git:12:找不到命令:___main _git:15:找不到命令:_default完成:13:找不到命令:compdef` (2认同)
  • 它显示 `git-completion.zsh:.:48: no such file or directory: _git:19: command not found: _default` 在 MacOS 11 上。 (2认同)

Jas*_*Jas 5

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

source ~/.profile