Skip to content

Commit

Permalink
Make cmd duration threshold configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
netmute authored and jorgebucaran committed Feb 22, 2023
1 parent d4c107a commit 41b46a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Display how many commits ahead and/or behind you are of your upstream—prompt r
~/p/<b>hydro</b> main ❱ ⎢
</pre>

Display [`$CMD_DURATION`](https://fishshell.com/docs/current/language.html?highlight=cmd_duration#envvar-CMD_DURATION) when > `1` second.
Display [`$CMD_DURATION`](https://fishshell.com/docs/current/language.html?highlight=cmd_duration#envvar-CMD_DURATION) when > `1` second. [Configurable](#configuration).

<pre>
~/p/<b>hydro</b> main ❱ git push --quiet
Expand Down Expand Up @@ -116,10 +116,11 @@ Modify variables using `set --universal` from the command line or `set --global`

### Misc

| Variable | Type | Description | Default |
| ---------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ | ------- |
| `fish_prompt_pwd_dir_length` | numeric | The number of characters to display when path shortening. Set it to `0` to display only the topmost (current) directory. | `1` |
| `hydro_ignored_git_paths` | strings | Space separated list of paths where no git info should be displayed. | `""` |
| Variable | Type | Description | Default |
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------ | ------- |
| `fish_prompt_pwd_dir_length` | numeric | The number of characters to display when path shortening. Set it to `0` to display only the topmost (current) directory. | `1` |
| `hydro_ignored_git_paths` | strings | Space separated list of paths where no git info should be displayed. | `""` |
| `hydro_cmd_duration_threshold` | numeric | Minimum command duration, in milliseconds, after which command duration is displayed. | `1000` |

## License

Expand Down
3 changes: 2 additions & 1 deletion conf.d/hydro.fish
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function _hydro_postexec --on-event fish_postexec
end
end

test "$CMD_DURATION" -lt 1000 && set _hydro_cmd_duration && return
test "$CMD_DURATION" -lt $hydro_cmd_duration_threshold && set _hydro_cmd_duration && return

set --local secs (math --scale=1 $CMD_DURATION/1000 % 60)
set --local mins (math --scale=0 $CMD_DURATION/60000 % 60)
Expand Down Expand Up @@ -134,3 +134,4 @@ 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_multiline || set --global hydro_multiline false
set --query hydro_cmd_duration_threshold || set --global hydro_cmd_duration_threshold 1000

0 comments on commit 41b46a0

Please sign in to comment.