首页 > 代码库 > 配合Git修改PS1

配合Git修改PS1

1.export PS1=‘\u@\h:\[\033[1;34m\]\w\[\033[0;33m\]$(git branch 2> /dev/null | sed -e ‘/^[^*]/d‘ -e "s/* \(.*\)/[\1$([[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*")]/")\[\e[0m\]$ ‘

source:http://ryansechrest.com/2013/11/bash-shell-prompt-dissected-display-git-branch-name-status-color/

2.curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

source:http://code-worrier.com/blog/git-branch-in-bash-prompt/

3.export PS1=‘\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] ‘

source:http://makandracards.com/makandra/524-show-the-current-git-branch-on-your-bash-prompt