Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git stash indicator with count (when greater than 1) #45

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Modify variables using `set --universal` from the command line or `set --global`
| `hydro_symbol_git_dirty` | string | Dirty repository symbol. | `•` |
| `hydro_symbol_git_ahead` | string | Ahead of your upstream symbol. | `↑` |
| `hydro_symbol_git_behind` | string | Behind of your upstream symbol. | `↓` |
| `hydro_symbol_git_stash` | string | Stash present symbol. | `≡` |

### Colors

Expand All @@ -109,10 +110,11 @@ Modify variables using `set --universal` from the command line or `set --global`

### Flags

| Variable | Type | Description | Default |
| ----------------- | ------- | -------------------------------------------- | ------- |
| `hydro_fetch` | boolean | Fetch git remote in the background. | `false` |
| `hydro_multiline` | boolean | Display prompt character on a separate line. | `false` |
| Variable | Type | Description | Default |
| ----------------- | ------- | -------------------------------------------- | ------- |
| `hydro_fetch` | boolean | Fetch git remote in the background. | `false` |
| `hydro_multiline` | boolean | Display prompt character on a separate line. | `false` |
| `hydro_stash_count` | boolean | Display git stash count. | `false` |

### Misc

Expand Down
10 changes: 9 additions & 1 deletion conf.d/hydro.fish
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ function _hydro_prompt --on-event fish_prompt
! command git diff-index --quiet HEAD 2>/dev/null ||
count (command git ls-files --others --exclude-standard) >/dev/null && set info \"$hydro_symbol_git_dirty\"

command git rev-list --walk-reflogs --count refs/stash 2>/dev/null | read stash_count
if test -n \"\$stash_count\" && test \"\$stash_count\" -gt 0
set stash \" $hydro_symbol_git_stash\"
test \"$hydro_stash_count\" = true && test \"\$stash_count\" -gt 1 && set stash \"\$stash\$stash_count\"
end

for fetch in $hydro_fetch false
command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
read behind ahead
Expand All @@ -92,7 +98,7 @@ function _hydro_prompt --on-event fish_prompt
set upstream \" $hydro_symbol_git_ahead\$ahead $hydro_symbol_git_behind\$behind\"
end

set --universal $_hydro_git \"\$branch\$info\$upstream \"
set --universal $_hydro_git \"\$branch\$info\$upstream\$stash \"

test \$fetch = true && command git fetch --no-tags 2>/dev/null
end
Expand Down Expand Up @@ -133,5 +139,7 @@ set --query hydro_symbol_prompt || set --global hydro_symbol_prompt ❱
set --query hydro_symbol_git_dirty || set --global hydro_symbol_git_dirty •
set --query hydro_symbol_git_ahead || set --global hydro_symbol_git_ahead ↑
set --query hydro_symbol_git_behind || set --global hydro_symbol_git_behind ↓
set --query hydro_symbol_git_stash || set --global hydro_symbol_git_stash ≡
set --query hydro_multiline || set --global hydro_multiline false
set --query hydro_stash_count || set --global hydro_stash_count false
set --query hydro_cmd_duration_threshold || set --global hydro_cmd_duration_threshold 1000