Setting colors for prompt in Git Bash on Windows

浪尽此生 提交于 2019-11-30 06:41:26

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).

Here's an example:

PS1='\[\033[1;36m\]\u@\h:\[\033[0m\]\[\033[1;34m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]\$ '

In order for the command substitution to work, you need shopt -s promptvars which is the default.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!