为什么要在Docker Quickstart Terminal报告下运行bash终端
bash: parse_git_branch: command not found
echo $BASH_VERSION
都显示相同的结果(3.2.53(1)-release)。cat ~/.bash_profile
都看到相同的内容,并且在底部明确定义了该函数:parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
最佳答案
Docker Quickstart Terminal似乎没有启动登录 shell ,因此未执行.bash_profile
。通常,您将在PS1
中设置.bashrc
的值,以便为所有交互式shell定义该值,这是大多数(全部?)Linux终端模拟器开始的工作。
在Mac OS X中,终端仿真器通常启动登录 shell 程序,因为它们本身不是从 shell 程序启动,而是由Finder启动。
好的做法是将提示设置为.bashrc
,但要从OS X下的.bash_profile
中获取该文件。
https://stackoverflow.com/questions/32280315/