Git Autocompletion:意外令牌"换行"附近的语法错误

Syl*_*lar 4 git bash git-bash

我已经看过关于这个问题的不同问题,似乎没有一个与我的相同:Mac 10.10.2上的新git安装

我使用下面的代码来安装自动完成功能:

curl -OL https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Run Code Online (Sandbox Code Playgroud)

我也试过以上:-O.

我在.已下载的文件中添加了一个:

mv ~/git-completion.bash ~/.git-completion.bash
Run Code Online (Sandbox Code Playgroud)

然后我编辑我的bash_profile并插入该行以在终端加载时获得自动加载:

if [ -f ~/.git-completion.bash ]; then
  source ~/.git-completion.bash
fi
Run Code Online (Sandbox Code Playgroud)

重新启动终端:

Users/user/.git-completion.bash: line 4: syntax error near unexpected token `newline'
Run Code Online (Sandbox Code Playgroud)

下载的文件或我的操作系统是否存在问题?

Jae*_*aek 5

curl -OL https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Run Code Online (Sandbox Code Playgroud)

这不是真正的'.bash'文件.(看起来像网站的html文件)

如果你想git-completion.bash文件,

连接网站" https://github.com/git/git "

和

点击"下载ZIP"按钮

谢谢.


Nob*_*obu -1

我遇到了类似的错误:git-completion.bash: line 155: syntax error near unexpected token。该文件看起来不错,所以我这样做了brew install bash,错误消失了。当前的一个是4.3.39,前一个是:

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Run Code Online (Sandbox Code Playgroud)

希望它对那些用谷歌搜索错误消息的人有所帮助。