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 dirty count to git dirty indicator #44

Open
wants to merge 6 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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,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_dirty_count` | boolean | Display git dirty count. | `false` |
| `hydro_fetch` | boolean | Fetch git remote in the background. | `false` |
| `hydro_multiline` | boolean | Display prompt character on a separate line. | `false` |

### Misc

Expand Down
15 changes: 12 additions & 3 deletions conf.d/hydro.fish
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ function _hydro_prompt --on-event fish_prompt

test -z \"\$$_hydro_git\" && set --universal $_hydro_git \"\$branch \"

! 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\"
if test \"$hydro_dirty_count\" = false
! command git diff-index --quiet HEAD 2>/dev/null ||
count (command git ls-files --others --exclude-standard) >/dev/null && set dirty \"$hydro_symbol_git_dirty\"
else
command git status --porcelain | count | read dirty_count
if test -n \"\$dirty_count\" && test \"\$dirty_count\" -gt 0
set dirty \"$hydro_symbol_git_dirty\"
test \"$hydro_dirty_count\" = true && test \"\$dirty_count\" -gt 1 && set dirty \"\$dirty\$dirty_count\"
end
end

for fetch in $hydro_fetch false
command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
Expand All @@ -92,7 +100,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\$dirty\$upstream \"

test \$fetch = true && command git fetch --no-tags 2>/dev/null
end
Expand Down Expand Up @@ -133,5 +141,6 @@ 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_dirty_count || set --global hydro_dirty_count false
set --query hydro_multiline || set --global hydro_multiline false
set --query hydro_cmd_duration_threshold || set --global hydro_cmd_duration_threshold 1000