Reputation: 12072
I have looked at different questions regarding this issue and none seem identical to mine: new git installation on Mac 10.10.2
I have used the below to install auto-completion:
curl -OL https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
I have also tried the above with: -O
.
I have added a .
to the file that was downloaded:
mv ~/git-completion.bash ~/.git-completion.bash
Then I edit my bash_profile
and inserted the line to get an auto load when terminal loads:
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
Up on restarting terminal:
Users/user/.git-completion.bash: line 4: syntax error near unexpected token `newline'
Is there an issue with the file that was download or my OS?
Upvotes: 7
Views: 7814
Reputation: 71
=>For Mac User
=> Install homebrew
=> Install Git and bash-completion: brew install git && brew install bash-completion (Note: If this install fails with a 404 error, and you already have git installed, just remove the git part of this brew install)
=> Add bash-completion to your ~/.bash_profile:
if [ -f brew --prefix
/etc/bash_completion.d/git-completion.bash ]; then
. brew --prefix
/etc/bash_completion.d/git-completion.bash
fi
Upvotes: 0
Reputation: 9488
You are using the wrong URL:
curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
Upvotes: 0
Reputation: 1172
The problem is caused by the newline characters in the downloaded file. So you can press the 'raw' button on the github page and copy the raw content of the script. Then replace the content of git-completion.bash with the raw content using your text editor, save it and good to go.
Upvotes: 0
Reputation: 500
I found a solution. I had an exact same error as yours.
git-completion.bash
file if any in your user foldermv ~/git-completion.bash ~/.git-completion.bash
nano .bash_profile
enter following code
`if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi`
git h
and press tab key for autocompletion of help.Upvotes: 1
Reputation: 427
curl -OL https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
this is not real '.bash' file. (looks like website html file)
if you want to git-completion.bash file,
connect site "https://github.com/git/git"
and
click on the "Download ZIP" button
thanks.
Upvotes: 5
Reputation: 10425
I got a similar error: git-completion.bash: line 155: syntax error near unexpected token
. The file looked fine, so I did brew install bash
and the error's gone. Current one is 4.3.39
and previous one was:
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Hope it helps for those who googled error message.
Upvotes: -1