summaryrefslogtreecommitdiff
path: root/README.md
blob: ce30d1b5e396e78fb78031d030fc751eca57d220 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# timr

A simple command-line tool to track time spent on tasks.

## About

`timr` is a minimalist stopwatch-style timer that runs in your terminal. It helps you track the time you spend on your work by allowing you to start, stop, and check the status of the timer. The timer's state is saved to your system, so you can pause your work and resume tracking later.

## Installation

To build and install `timr`, you need to have Go installed on your system. You can then build the executable by running the following command in the project's root directory:

```bash
go build ./...
```

This will create a `timr` executable in the current directory. To make it accessible from anywhere, you can move it to a directory in your system's `PATH`, such as `/usr/local/bin`:

```bash
sudo mv timr /usr/local/bin/
```

## Usage

`timr` provides the following commands:

*   `timr start`: Starts the timer. If the timer was previously stopped, it will resume from where it left off.
*   `timr stop` or `timr pause`: Stops or pauses the timer. The elapsed time will be saved.
*   `timr status`: Shows the current status of the timer (running or stopped) and the total elapsed time.
*   `timr reset`: Resets the timer. This will set the elapsed time to zero.
*   `timr live`: Shows a live, full-screen timer with keyboard controls (q: quit, s: start/stop, r: reset).

## Fish Shell Integration

`timr` can be integrated with the fish shell to display the current timer status in your prompt.

### 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:

    ```fish
    function fish_prompt
        # ... your existing prompt ...
        printf ' %s' (timr_prompt)
    end
    ```