New prompt methods on Git lib file
| ... | ... |
@@ -4,7 +4,8 @@ function git_prompt_info() {
|
| 4 | 4 |
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
| 5 | 5 |
} |
| 6 | 6 |
|
| 7 |
-parse_git_dirty () {
|
|
| 7 |
+# Checks if working tree is dirty |
|
| 8 |
+parse_git_dirty() {
|
|
| 8 | 9 |
if [[ -n $(git status -s 2> /dev/null) ]]; then |
| 9 | 10 |
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" |
| 10 | 11 |
else |
| ... | ... |
@@ -12,7 +13,24 @@ parse_git_dirty () {
|
| 12 | 12 |
fi |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
-# get the status of the working tree |
|
| 15 |
+# Checks if there are commits ahead from remote |
|
| 16 |
+function git_prompt_ahead() {
|
|
| 17 |
+ if $(echo "$(git log origin/master..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then |
|
| 18 |
+ echo "$ZSH_THEME_GIT_PROMPT_AHEAD" |
|
| 19 |
+ fi |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+# Formats prompt string for current git commit short SHA |
|
| 23 |
+function git_prompt_short_sha() {
|
|
| 24 |
+ SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+# Formats prompt string for current git commit long SHA |
|
| 28 |
+function git_prompt_long_sha() {
|
|
| 29 |
+ SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 32 |
+# Get the status of the working tree |
|
| 16 | 33 |
git_prompt_status() {
|
| 17 | 34 |
INDEX=$(git status --porcelain 2> /dev/null) |
| 18 | 35 |
STATUS="" |
| ... | ... |
@@ -41,4 +59,4 @@ git_prompt_status() {
|
| 41 | 41 |
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" |
| 42 | 42 |
fi |
| 43 | 43 |
echo $STATUS |
| 44 |
-} |
|
| 44 |
+} |
|
| 45 | 45 |
\ No newline at end of file |