sh 更改PS1提示+添加git分支
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 更改PS1提示+添加git分支相关的知识,希望对你有一定的参考价值。
# Git branch in prompt.
BLACK="\[$(tput setaf 0)\]"
RED="\[$(tput setaf 1)\]"
GREEN="\[$(tput setaf 2)\]"
DARK_BLUE="\[$(tput setaf 4)\]"
PURPLE="\[$(tput setaf 5)\]"
LIGHT_BLUE="\[$(tput setaf 6)\]"
LIGHT_GREY="\[$(tput setaf 7)\]"
DARK_GREY="\[$(tput setaf 8)\]"
RESET="\[$(tput sgr0)\]"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="[\A] \u:\w${GREEN}\$(parse_git_branch)${RESET}$ "
以上是关于sh 更改PS1提示+添加git分支的主要内容,如果未能解决你的问题,请参考以下文章