From 8da786bef7d3121f93a24f18ed7d8699d4279097 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 8 Nov 2025 12:12:17 +0200 Subject: rename script to fish shell script --- README.md | 2 +- install-fish-integration.fish | 55 +++++++++++++++++++++++++++++++++++++++++++ install-fish-integration.sh | 55 ------------------------------------------- 3 files changed, 56 insertions(+), 56 deletions(-) create mode 100755 install-fish-integration.fish delete mode 100755 install-fish-integration.sh diff --git a/README.md b/README.md index a04e98b..f70f2a2 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ sudo mv timr /usr/local/bin/ Run the installation script: ```bash -./install-fish-integration.sh +./install-fish-integration.fish ``` Then update your `fish_prompt` or `fish_right_prompt` function to include the `timr_prompt` function as shown in the script output. diff --git a/install-fish-integration.fish b/install-fish-integration.fish new file mode 100755 index 0000000..53d864e --- /dev/null +++ b/install-fish-integration.fish @@ -0,0 +1,55 @@ +#!/usr/bin/env fish + +set -l fish_config_dir (set -q XDG_CONFIG_HOME; and echo "$XDG_CONFIG_HOME/fish"; or echo "$HOME/.config/fish") +set -l fish_conf_d "$fish_config_dir/conf.d" +set -l integration_file "$fish_conf_d/timr.fish" + +echo "Installing timr fish shell integration..." + +# Create fish config directory if it doesn't exist +if not test -d "$fish_conf_d" + mkdir -p "$fish_conf_d" + echo "Created directory: $fish_conf_d" +end + +# Write the integration file +echo "\ +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\" +" > "$integration_file" + +echo "Created: $integration_file" +echo "" +echo "Installation complete!" +echo "" +echo "To display timr in your prompt, add this to your fish_prompt or fish_right_prompt:" +echo "" +echo " function fish_prompt" +echo " # ... your existing prompt ..." +echo " printf '%s ' (timr_prompt)" +echo " end" +echo "" +echo "Restart your fish shell or run 'source $integration_file' to apply changes." diff --git a/install-fish-integration.sh b/install-fish-integration.sh deleted file mode 100755 index 53d864e..0000000 --- a/install-fish-integration.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env fish - -set -l fish_config_dir (set -q XDG_CONFIG_HOME; and echo "$XDG_CONFIG_HOME/fish"; or echo "$HOME/.config/fish") -set -l fish_conf_d "$fish_config_dir/conf.d" -set -l integration_file "$fish_conf_d/timr.fish" - -echo "Installing timr fish shell integration..." - -# Create fish config directory if it doesn't exist -if not test -d "$fish_conf_d" - mkdir -p "$fish_conf_d" - echo "Created directory: $fish_conf_d" -end - -# Write the integration file -echo "\ -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\" -" > "$integration_file" - -echo "Created: $integration_file" -echo "" -echo "Installation complete!" -echo "" -echo "To display timr in your prompt, add this to your fish_prompt or fish_right_prompt:" -echo "" -echo " function fish_prompt" -echo " # ... your existing prompt ..." -echo " printf '%s ' (timr_prompt)" -echo " end" -echo "" -echo "Restart your fish shell or run 'source $integration_file' to apply changes." -- cgit v1.2.3