diff --git a/README.md b/README.md index a73a308..f3810d6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/conf.d/hydro.fish b/conf.d/hydro.fish index 322f153..5999fdc 100644 --- a/conf.d/hydro.fish +++ b/conf.d/hydro.fish @@ -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 | @@ -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 @@ -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