Skip to content

Commit c1101a9

Browse files
committed
update to most recent __git_ps1_improved
1 parent cf0859f commit c1101a9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ master ✕✓? ↑1↓5
1919
...with the original git prompt
2020

2121
```bash
22-
master *+% u+1-5
22+
master *+%|u+1-5
2323
```
2424

2525
## Usage

bash-git-prompt

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ GIT_PS1_SHOWUNTRACKEDFILES=true
66
GIT_PS1_SHOWUPSTREAM="verbose"
77

88
__git_ps1_improved() {
9-
local git_current_branch_name="\$(__git_ps1 '%s' | sed 's/ .\+//' | sed -e 's/[\\\\/&]/\\\\\\\\&/g')"
109
local git_status_substitutes=(
11-
"s/$git_current_branch_name//;" # remove branch temporarily
12-
"s/u//;" # upstream
13-
"s/+\([0-9]\+\)/↑\1/;" # outgoing
14-
"s/-\([0-9]\+\)/↓\1/;" # incoming
15-
"s/%/?/;" # untracked
16-
"s/+/✓/;" # staged
17-
"s/*/✕/;" # unstaged
18-
"s/\(.*\)/⑂ $git_current_branch_name\1/;" # insert branch again
10+
"s/|u=/ =/;" # equal to upstream
11+
"s/|u+\([0-9]\+\)-\([0-9]\+\)/ ↑\1↓\2/;" # diverged from upstream
12+
"s/|u+\([0-9]\+\)/ ↑\1/;" # ahead of upstream
13+
"s/|u-\([0-9]\+\)/ ↓\1/;" # behind upstream
14+
"s/%/?/;" # untracked
15+
"s/+/✓/;" # staged
16+
"s/*/✕/;" # unstaged
1917
)
2018

21-
echo "\$(__git_ps1 '%s'| sed \"${git_status_substitutes[@]}\")"
19+
echo "\$(__git_ps1 '%s'| sed \"${git_status_substitutes[@]}\")"
2220
}

0 commit comments

Comments
 (0)