export PS1='$(git branch 2>/dev/null | grep "*" | sed "s/* //") \w\$ '

Category: Terminal Configuration

export PS1='$(git branch 2>/dev/null | grep "*" | sed "s/* //") \w\$ '

Add the current git branch to your bash prompt

Runs `git branch` on every prompt render, extracts the active branch name, and displays it before the working directory. This is a basic approach — for a faster, richer git prompt, consider Starship or __git_ps1 from git's bash completion.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.