我尝试按照教程@ https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
进行操作这是我的〜/ .bash_profile:
export PATH="/usr/local/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="/usr/local/bin:$PATH"
alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
alias gl="git log --all --oneline --decorate --graph --pretty=format:'%h - %C(cyan)%an%Creset, %Cred%d%Creset %C(yellow)%ar%Creset : %s'"
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
if [ -f $(brew --prefix)/etc/bash_completion ]; then
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
#PS1='\u: \W$(__git_ps1 "[%s]") \$ '
PS1='\[\e[32m\]\u: \W$(__git_ps1 "[%s]") \$\[\e[m\] '
fi
打开终端时出现的错误:
-bash: .: command not found
-bash: GIT_PS1_SHOWDIRTYSTATE=true: command not found
-bash: GIT_PS1_SHOWUNTRACKEDFILES=true: command not found
-bash: #PS1=\u: \W$(__git_ps1 "[%s]") \$ : command not found
-bash: PS1=\[\e[32m\]\u: \W$(__git_ps1 "[%s]") \$\[\e[m\] : command not found
我希望我的PS1看起来像
(user name): (current directory)(current repo branch *status*) $:
感谢任何帮助。
答案 0 :(得分:3)
比较在shell手动输入bogus命令的输出:
$ felkj
-bash: felkj: command not found
到您从脚本中获得的输出:
-bash: .: command not found
-bash: GIT_PS1_SHOWDIRTYSTATE=true: command not found
-bash: GIT_PS1_SHOWUNTRACKEDFILES=true: command not found
-bash: #PS1=\u: \W$(__git_ps1 "[%s]") \$ : command not found
-bash: PS1=\[\e[32m\]\u: \W$(__git_ps1 "[%s]") \$\[\e[m\] : command not found
查看-bash:
之后的额外空格?那是你的问题。
不知何故,您设法将非ascii空间放入脚本文件中。再次编辑它们并确保在这些行上使用ascii空格而不是'EN SPACE'(U + 2002)。