Reputation: 549
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
Upvotes: 19
Views: 13020
Reputation: 119
Edit the file with
sudo nano ~/.zshrc
provide your password and add the following to the end of the file
autoload -Uz compinit && compinit
relaunch your shell and you should have git completions
git checkout my_branch<tab>
should tab complete the branch name for you.
Upvotes: 0
Reputation: 549
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!
Upvotes: 18
Reputation: 1265
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
Upvotes: 2
Reputation: 63892
From your error report:
case "$COMP_WORDBREAK'" in
^ the problem is in unpaired apostrophe
Upvotes: 1
Reputation: 31
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".
Upvotes: 3
Reputation: 32927
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.
Upvotes: 1