Autocomplete git in mac OS not working?

你离开我真会死。 提交于 2020-07-31 07:37:07

问题


I am using git in mac. I am trying to have the autocomplete feature. I followed these steps (http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/) but I get this error, any idea?

: command not found -bash: /Users/me/git-completion.bash: line 80: syntax error near unex'ected token in -bash: /Users/me/git-completion.bash: line 80:case "$COMP_WORDBREAK'" in


回答1:


I had tried to use curl -O but the url was wrong and I ended up copying the text which caused the error.

Using this command made it work perfectly:

curl -O https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash

Thanks a lot everyone for your help!




回答2:


The git-completion.bash distributed is a Windows file with "\n\r" as a newline. You need to remove the '\r'.

For vim users, just do ":set ff=unix".




回答3:


Since nobody's answering, quick sanity check: What does bash --version say? OS X tends to ship slightly outdated bashes, so if your system is old, it might be a compatibility thing. I'd expect that Bash 3.x works fine, but with 2.x I'm not so sure.




回答4:


From your error report:

case "$COMP_WORDBREAK'" in
                     ^ the problem is in unpaired apostrophe 



回答5:


save the file e.g. in gedit with Linux Line-Ending




回答6:


Was getting .git-completion.bash: bash: bad interpreter: No such file or directory in Mountain Lion.

Should be "source ~/.git-completion.bash" in ~/.bash_profile



来源:https://stackoverflow.com/questions/4569463/autocomplete-git-in-mac-os-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!