|
| 1 | +# Git prompt for bash |
| 2 | + |
| 3 | +Bash prompt written in pure bash script. |
| 4 | + |
| 5 | +Under the hood the [git prompt provided by |
| 6 | +git](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh) |
| 7 | +is used. As that script does all the logic already, but outputs a rather |
| 8 | +cryptic status line, the only thing this script does is replace the output by |
| 9 | +more intuitive icons. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +Comparing the output of this script... |
| 14 | + |
| 15 | +```bash |
| 16 | +master ✕✓? ↑1↓5 |
| 17 | +``` |
| 18 | + |
| 19 | +...with the original git prompt |
| 20 | + |
| 21 | +```bash |
| 22 | +master *+% u+1-5 |
| 23 | +``` |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +1. Download the script |
| 28 | + ```bash |
| 29 | + curl https://raw.githubusercontent.com/koffeinfrei/bash-git-prompt/master/bash-git-prompt > ~/.bash-git-prompt |
| 30 | + ``` |
| 31 | + |
| 32 | +1. Add the following to your `.bash_profile` (or `.bashrc` or whatever bash |
| 33 | + initialize script you use): |
| 34 | + ```bash |
| 35 | + # 1. Exposes the function `__git_ps1_improved` |
| 36 | + source ~/.bash-git-prompt |
| 37 | + |
| 38 | + # 2. Include the function `__git_ps1_improved` in your `PS1`. |
| 39 | + # This is just an example of a prompt with `\w` outputting your current |
| 40 | + # directory. |
| 41 | + PS1="\w $(__git_ps1_improved) ➜ " |
| 42 | + ``` |
| 43 | + |
| 44 | +## Caption |
| 45 | + |
| 46 | +Symbol | Meaning |
| 47 | +-------- | ------- |
| 48 | +⑂ master | Current branch |
| 49 | +✕ | Unstaged changes |
| 50 | +✓ | Staged changes |
| 51 | +? | Untracked files |
| 52 | +↑1 | One changeset ahead of remote |
| 53 | +↓5 | Five changesets behind remote |
| 54 | += | No difference to remote |
| 55 | +\# | No HEAD to compare against (usually only happens before initial commit |
| 56 | + |
| 57 | +## See also |
| 58 | + |
| 59 | +[Bash prompt](https://github.com/koffeinfrei/bash-prompt) implements a custom |
| 60 | +bash prompt including this custom git prompt. |
| 61 | + |
| 62 | +The initial version of this script was introduced in the blogpost [git bash |
| 63 | +prompt](https://www.koffeinfrei.org/2013/07/05/git-bash-prompt/), which |
| 64 | +describes the implementation in more detail. |
0 commit comments