:此脚本已弃用,请参阅git-completion.zsh

8gsdolmq  于 10个月前  发布在  Git
关注(0)|答案(5)|浏览(223)

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

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

字符串
有什么解决办法吗?

2admgd59

2admgd591#

可能看起来很傻,但请确保您的~/.zshrc文件的源代码(如果不存在,请创建一个)。
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,你会很好

qv7cva1a

qv7cva1a2#

在Git for Windows中,如果shell不是Bash,则在执行文件etc/profile.d/git-prompt.sh时会发出此消息。
git-prompt.sh在不查看shell名称的情况下获取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)

字符串

wj8zmpe1

wj8zmpe13#

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

kzipqqlq

kzipqqlq4#

我在git for windows中也遇到了这个问题。原因如wl2776所述。
对我来说,我通过使用https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh中的脚本替换etc/profile.d/git-prompt.sh来解决这个问题

ffscu2ro

ffscu2ro5#

在您的控制台中键入以下内容:
第一个月
.profile/.bashrc/.zshrc中添加以下内容:
source ~/git-completion.zsh

相关问题