Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ Git Time Metrics (GTM) is a tool to automatically track time spent reading and w
Installing GTM is a two step process. First, it's recommended you install the GTM executable that the plug-in integrates with and then install the Terminal GTM plug-in. Please submit an issue if you have any problems and/or questions.

1. Follow the [Getting Started](https://github.com/git-time-metric/gtm/blob/master/README.md) section to install the GTM executable for your operating system.
2. To install the plugin download the shell script and `source gtm-plugin.sh` from either your .bashrc or .zshrc file. Also make sure the shell script is executable `chmod +x gtm-plugin.sh`.

#### Bash/Zsh
To install the plugin download the shell script and `source gtm-plugin.sh` from either your .bashrc or .zshrc file. Also make sure the shell script is executable `chmod +x gtm-plugin.sh`.

#### Fish
To install the plugin download the fish script and `source gtm-plugin.fish` from
`~/.config/fish/config.fish`


**Note** - to enable time tracking for a Git repository, you need to initialize it with `gtm init` otherwise it will be ignored by GTM. This is done via the command line.
```
Expand Down
22 changes: 22 additions & 0 deletions gtm-plugin.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env fish

set -x GTM_STATUS ""
set -x GTM_NEXT_UPDATE 0
set -x GTM_LAST_DIR {$PWD}

function gtm_record_terminal --on-event fish_prompt
set epoch (date +%s)
if test $GTM_LAST_DIR != {$PWD} -o $epoch -ge $GTM_NEXT_UPDATE
set -x GTM_NEXT_UPDATE (math $epoch + 30)
set -x GTM_LAST_DIR {$PWD}
if set -q GTM_STATUS_ONLY
set -x GTM_STATUS (gtm status -total-only)
else
set -x GTM_STATUS (gtm record -terminal -status)
end
if test $status -ne 0
echo "Error running 'gtm record -terminal -status', you may need to install gtm or upgrade to the latest"
echo "See http://www.github.com/git-time-metric/gtm for how to install"
end
end
end