Git Prompt: a function for adding nominal git info to the Linux Bash command prompt.
Currently includes
- Indicators of:
- untracked, modified, or added files to the index
- merge conflicts
- sync with origin(+ is ahead, - is behind)
- incomplete/complete merge/rebase
- stashed changes
- The current branch and refname for HEAD
Usage
Copy/paste the code in the file at the end of your .bashrc file. The extra info shows for all git repositories. Shows only in the working directory - not in a bare repository or inside the .git folder.
Commands: As it is now, this utility is not designed to take any input from the user. I could get around to adding a settings file sometime, but that's about it.
Indicator glossary
Indicator | Color | Meaning |
---|---|---|
S | Blue | You have stashed changes. |
C | Red | The latest action(cherry-pick, merge, rebase, ...) caused conflicts. |
U | Red | Untracked files are present in your directory. |
M | Red | You have modified files that are not added to index. |
A | Green | Files are present in index. |
Mrg | Red | Unfinished merge(due to conflicts). |
Green | Finished merge - make commit to proceed. | |
Rbs | Red | Unfinished rebase - the current commit has conflicts. |
Cont | Green | Conflicts fixed - proceed(with creating commit or continuing rebase/cherry-pick). |
HEAD detached at | Red | Similar to 'git status', indicates a detached HEAD state. |
+m/0 | Green | You are m commits ahead of origin - push your changes. |
0/-n | Blue | (After you do a fetch) you are behind origin by n commits. Merge changes. |
+m/-n | Green/Blue | Both of the above at the same time(indicates a diverged branch - do a rebase) |
Acknowledgements
Contains code taken from http://www.opinionatedprogrammer.com/2011/01/colorful-bash-prompt-reflecting-git-status/
Thanks to Jo Liss for letting me use her code in my project. It's much appreciated.
If you have any suggestions, feel free to post them. Pull requests also welcome.