summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-11-08 12:11:38 +0200
committerPaul Buetow <paul@buetow.org>2025-11-08 12:11:38 +0200
commitdf21f29d78a34ea7e5d360377749d5150d839461 (patch)
tree936d4e03b7ed67bc845dc7daf84ffd90dbf380a0
parentcdb222fc402ec19652e9fb183423594c1fb8148b (diff)
fix bug
-rw-r--r--README.md41
-rw-r--r--internal/timer/timer.go5
2 files changed, 10 insertions, 36 deletions
diff --git a/README.md b/README.md
index f5dd26c..a04e98b 100644
--- a/README.md
+++ b/README.md
@@ -41,41 +41,10 @@ sudo mv timr /usr/local/bin/
### Installation
-Add this to your fish config:
-
-```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:
+Run the installation script:
-```fish
-function fish_prompt
- # ... your existing prompt ...
- printf ' %s' (timr_prompt)
-end
+```bash
+./install-fish-integration.sh
```
+
+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/internal/timer/timer.go b/internal/timer/timer.go
index e8585d5..272233a 100644
--- a/internal/timer/timer.go
+++ b/internal/timer/timer.go
@@ -65,5 +65,10 @@ func (s *State) Save() error {
return err
}
+ dir := filepath.Dir(stateFilePath)
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ return err
+ }
+
return os.WriteFile(stateFilePath, data, 0644)
}