Zum Hauptinhalt wechseln

How to show current git branch with colors in Bash prompt

A quick hack, for more information (for example colors) go to the source .

Adding this to ~/.bashrc:

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "

Kommentare

Noch keine Kommentare zu diesem Beitrag.