Git/color prompt

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Git
Revision as of 22:11, 8 January 2023 by Woozle (talk | contribs) (Created page with "To show the status of the current project in the bash prompt, using color, add this to <code>~/.bashrc</code>: <syntaxhighlight lang=bash> parse_git_branch() { git branch...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To show the status of the current project in the bash prompt, using color, add this to ~/.bashrc:

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[01;32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

I think the location is significant; in my files, it's right after PS1 is first defined.