54

I'm using oh-my-zsh and I get this error every time I open terminal:

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

is there any solution to that?

1
  • 8
    I think this is a good question, since many times people will simply google a warning that appears in their command line. Feb 20, 2015 at 7:54

4 Answers 4

42

Might seems silly, but make sure that you source your ~/.zshrc file (create one if it does not exists). On OSX I completely forgot that I had switched to zsh, and got the error you mentioned because I was doing source ~/.bashrc

  1. The easiest way to get auto-completion working is to install it through Homebrew (it will work for zsh as well as bash.):
brew install bash-completion
  1. Put this into your ~/.zshrc:
# auto-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
  . /opt/local/etc/profile.d/bash_completion.sh
fi
  1. Save the file and do a source ~/.zshrc and you will be good
7
  • 6
    This solved a 2-hour struggle for me after I switched to zsh. Thank you!
    – dimitarvp
    Mar 5, 2019 at 22:04
  • 2
    You saved me so much time. Thank you! I just switched to macOS and you're the only person who told me to create a ~/.zshrc
    – Fowad
    Dec 25, 2020 at 19:19
  • 1
    Tks bro, i am new im Mac. Tks <3 Mar 7, 2021 at 23:47
  • 2
    @EzequielDeSimone I had to comment out "#source ~/git-completion.bash" in my zshrc to clear the warning even after following the instructions on this answer. Maybe that might help too.
    – Eaweb
    May 7, 2021 at 8:51
  • 2
    For this issue, my colleague just needed to remove references to bash_completion in the .zshrc file. We use ohmyzsh and autocompletion is already implemented. Jan 26, 2022 at 16:33
5

For me, I simply had copied over the contents of ~/.bash_profile to ~/.zprofilewhen migrating to zsh. I simply removed this line which was the root cause of the warning message:

source ~/.profile

2
  • source: no such file or directory: /Users/myuser/.profile Apr 21, 2021 at 14:16
  • 1
    @IgorGanapolsky Looks like ~/.profile does not exist, so if you remove that line when copying over from ~/.bash_profile to ~/.zprofile you should not get that error
    – Jas
    Apr 22, 2021 at 21:15
2

In Git for Windows, this message is emitted during execution of the file etc/profile.d/git-prompt.sh, if the shell is not Bash.

git-prompt.sh sources git-completion.bash without looking at the shell name. That file checks that it is not run by Bash, emits that warning message and exits.

Here is the link to the respective code: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash#L3509

You should look inside git-completion.zsh located in the same directory near this file and follow installation instructions provided in the comments in the beginning:

# 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)
-1

Type this in your console:

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

Add this in one of your .profile / .bashrc / .zshrc:

source ~/git-completion.zsh

3
  • 30
    I get the following errors from my zsh: zsh:12: command not found: ___main (eval):1: no matches found: *:all-files _tags:comptags:36: can only be called from completion function _tags:comptry:55: can only be called from completion function _tags:comptags:60: can only be called from completion function _tags:comptags:67: can only be called from completion function zsh --version zsh 5.0.5 (x86_64-pc-linux-gnu) # I also use Oh My Zsh. Feb 20, 2015 at 8:07
  • 9
    _git:12: command not found: ___main _git:15: command not found: _default complete:13: command not found: compdef
    – user5306470
    Jul 18, 2019 at 1:53
  • 3
    It says git-completion.zsh:.:48: no such file or directory: _git:19: command not found: _default at MacOS 11. Nov 18, 2020 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.