我为我的 OS X 终端编写了这个漂亮而多彩的提示:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/'
}
export PS1="\e]2;\w\a\e[1;30;1m\][\u@\[\033[0;36m\]\h\e[1;30;1m\]:\[\033[0;35m\]\w\e[1;30;1m\]] \[\033[0;31m\](\t) \[\033[0;33m\]\$(parse_git_branch)\n\[\033[0m\]\e[1;30;1m\]\$\[\e[0m\]"
Run Code Online (Sandbox Code Playgroud)
我source ~/.bash_profile
它,它工作正常。除了当我使用向上箭头浏览历史时,我会发生一件奇怪的事情。
基本上是source ~/.bash_profile
历史命令的开头,成为提示的一部分。当我ctrl+c
或enter
它恢复正常时,但只要我看到source
命令的历史记录,提示就会再次更改。
这是我看过历史然后ctrl+u
输入的示例ls
:
[user@host:~/Documents] (14:01:40) [branch]
$source ~/.ls
Run Code Online (Sandbox Code Playgroud)
关于这个的任何线索?