用git当前分支和颜色PS1线 [英] PS1 line with git current branch and colors
问题描述
下面是我目前的PS1
Here is my current PS1
export PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
我怎么能以不同的颜色显示当前的分支?
How can I display the current branch in a different color?
推荐答案
你可以用你想要的颜色朱朱的以下位部分:
You can wrap the part that you want in colour in the following bits of juju:
\\ E [0;32米
- 设置颜色(在这种情况下,绿色)
\e[0;32m
- sets colour (in this case, to green)
\\ E [M
- 设置颜色恢复到默认
\e[m
- sets colour back to the default
例如,这台提示当前路径的最后一个道理,在绿色,
其次是在$默认的颜色:
For example, this sets the prompt to the last token of the current path, in green, followed by $ in the default colour:
出口PS1 ='\\ E [0;32米\\ W \\ E [M $
其他的颜色可供选择! :-)看一看根据着色这篇文章的COM $ P $替代phensive列表。
Other colours are available! :-) Have a look at this article under colorization for a comprehensive list of alternatives.
这篇关于用git当前分支和颜色PS1线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!