Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git-prompt.sh输出中的颜色_Git_Bash_Prompt - Fatal编程技术网

git-prompt.sh输出中的颜色

git-prompt.sh输出中的颜色,git,bash,prompt,Git,Bash,Prompt,我正试图修改git-prompt.sh,用更可读的版本替换*/+repo状态指示器,例如“更改”/“暂存文件” 只是改变文字是很容易的,但我也希望他们不同的颜色。简单地将一些颜色转义序列(如\[\e[33m\])粘贴到状态描述字符串中是不起作用的;转义序列等只是转储到输出中 当从git-prompt.sh脚本输出时,有什么方法可以让bash理解颜色吗?似乎您必须使用tput颜色 来自 有关颜色列表,请参见和。为了澄清,这些更改不在.bashrc中(设置PS1并调用_git_PS1时,它已经在那里

我正试图修改git-prompt.sh,用更可读的版本替换*/+repo状态指示器,例如“更改”/“暂存文件”

只是改变文字是很容易的,但我也希望他们不同的颜色。简单地将一些颜色转义序列(如
\[\e[33m\]
)粘贴到状态描述字符串中是不起作用的;转义序列等只是转储到输出中


当从git-prompt.sh脚本输出时,有什么方法可以让bash理解颜色吗?

似乎您必须使用
tput
颜色

来自


有关颜色列表,请参见和。

为了澄清,这些更改不在.bashrc中(设置PS1并调用_git_PS1时,它已经在那里工作了,但它的所有输出都将获得一种颜色),而是在git-prompt.sh中。但是,在那里使用tput确实有效。唯一的问题是它还将输出[]在结果中,我删除了这些,得到了我想要的结果。谢谢!
YELLOW="\[$(tput setaf 3)\]"
RESET="\[$(tput sgr0)\]"

PS1="\h:\W \u\$(__git_ps1 \" ${YELLOW}(%s)${RESET} \")\$ "