Last active
February 26, 2026 13:41
-
-
Save tbnorth/6190181da468adf07afe9d66cc517a04 to your computer and use it in GitHub Desktop.
Fast Git Bash (Windows) git status prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Paste this at end of .bashrc | |
| # Replacing "On branch" with " " makes sure the branch-name sorts first in `sort -u` | |
| # sort -u removes duplicate x!? chars. for multiple deleted / modified / unknown files | |
| # final sed strips leading space and linebreaks and adds [] | |
| function fast_git_ps1 { | |
| git status 2>&1 | sed -En ' | |
| /On branch/ {s/On branch / /; s/$/ /; H} | |
| /deleted:/ {s/.*/x/; H} | |
| /modified:/ {s/.*/!/; H} | |
| /Untracked files/ {s/.*/?/; H} | |
| /ahead of/ {s/.*/*/; H} | |
| /behind/ {s/.*/</; H} | |
| /dubious ownership/ {s/.*/ERR:see git status/; H} | |
| $ {x; p}' | sort -u | sed -En 's/^ //; H; $ {x; s/\n//g; s/^/[/; H; s/ ?$/]/; s/\[]//; p}' | |
| } | |
| PS1="${PS1/__git_ps1/fast_git_ps1}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment