Skip to content

Instantly share code, notes, and snippets.

View chrisnolet's full-sized avatar

Chris Nolet chrisnolet

View GitHub Profile
@chrisnolet
chrisnolet / .bash_profile
Last active September 27, 2022 13:37 — forked from henrik/.bashrc
Color-coded git branch for bash prompt
git_branch() {
local branch=$(git --no-optional-locks branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* (*\([^)]*\))*/\1/')
if [[ -n $branch ]]; then
if [[ -z $(git --no-optional-locks status --porcelain 2> /dev/null) ]]; then
echo -e " \001\033[32m\002($branch)\001\033[0m\002"
else
echo -e " \001\033[31m\002($branch)\001\033[0m\002"
fi
fi