问题描述
我已经成功地与一些在Git的击在Windows颜色设置发挥各地 - 我能够在我的<$ C $设置一些东西,比如地方,当前和远程分支机构的颜色C>的.gitconfig 文件:
I've successfully played around with some of the color settings in the Git Bash on Windows - I'm able to set a few things, like the colors of the local, the current and remote branches in my .gitconfig
file:
[color "branch"]
current = cyan bold
local = cyan
remote = red
但我没有设法改变是提示的颜色 - 在用户名@机
在该行的开头(在我的截图黄色矩形),以及项目和分支目前我在(紫色矩形)。
But what I haven't managed to change are the colors of the prompt - the username@machine
at the beginning of the line (in the yellow rectangle in my screenshot), and the project and branch I'm currently on (purple rectangle).
有没有办法去影响那些呢?其中的.gitconfig
设置,我需要设置为改变这些颜色吗?
Is there a way to influence those, too? Which .gitconfig
settings do I need to set to change those colors?
推荐答案
在你的的.bashrc
您可以使用设置提示PS1
变量(这很可能设置为 / etc / profile文件或的/ etc 这可能是分布而定)。
In your .bashrc
you can set your prompt using the PS1
variable (which is likely set to a global value in /etc/profile
or another file in /etc
which may be distribution dependent).
下面是一个例子:
PS1='\[\033[1;36m\]\u@\h:\[\033[0m\]\[\033[1;34m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]\$ '
为了使命令替换工作,你需要禁用了javascript -s promptvars
这是默认的。
这将输出青色用户和主机名,在蓝色的当前目录和绿色的Git分支上一起工作的终端 TERM = xterm的色
。
This will output the user and hostname in cyan, the current directory in blue and the git branch in green on terminals that work with TERM=xterm-color
.
请参阅和的有关终端控制的更多信息。
See man 5 terminfo
and man tput
for more information about terminal controls.
这篇关于在Windows上设置了颜色提示Git中的Bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!