From f66b8ee57631597acc46739dd4735b0eae45a2ed Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 26 Jun 2025 00:21:38 +0300 Subject: fix fish shell integration --- README.md | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6d92f9f..ce30d1b 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,38 @@ sudo mv timr /usr/local/bin/ ### Installation -1. Copy the `integrations/fish-shell` directory to your fish plugins directory: +Add this to your fish config: - ```bash - cp -r integrations/fish-shell ~/.config/fish/plugins/timr + ```fish + function timr_prompt -d "Display timr timr_status in the prompt" + if command -v timr >/dev/null + set -l timr_status (timr prompt) + if test -n "$timr_status" + set -l icon (string sub -l 1 -- "$timr_status") + set -l time (string sub -s 2 -- "$timr_status") + if test "$icon" = "▶" + set_color green + else + set_color yellow + end + printf '%s' "$icon" + set_color normal + printf ' %s' "$time" + end + end + end + + complete -c timr -n __fish_use_subcommand -a start -d "Start the timer" + complete -c timr -n __fish_use_subcommand -a stop -d "Stop the timer" + complete -c timr -n __fish_use_subcommand -a pause -d "Pause the timer" + complete -c timr -n __fish_use_subcommand -a status -d "Show the timer status" + complete -c timr -n __fish_use_subcommand -a reset -d "Reset the timer" + complete -c timr -n __fish_use_subcommand -a live -d "Show the live timer" + complete -c timr -n __fish_use_subcommand -a prompt -d "Show the prompt status" ``` -2. Update your `fish_prompt` or `fish_right_prompt` function to include the `timr_prompt` function. For example, you can add the following to your `~/.config/fish/functions/fish_prompt.fish` file: + +2. Update your `fish_prompt` or `fish_right_prompt` function to include the `timr_prompt` function: ```fish function fish_prompt -- cgit v1.2.3