git_branch() {
git symbolic-ref --short HEAD 2>/dev/null
}
# Append to PS1 — change colors as you like
export PS1='\u@\h \w \[\e[36m\]$(git_branch)\[\e[0m\]\$ '
# With "dirty" indicator (* if there are uncommitted changes)
git_dirty() {
[[ -n "$(git status --porcelain 2>/dev/null)" ]] && echo "*"
}
export PS1='\u@\h \w \[\e[36m\]$(git_branch)$(git_dirty)\[\e[0m\]\$ '
Create a free account and build your private vault. Share publicly whenever you want.