diff --git a/README.md b/README.md index 7b0338b..cbfb64d 100644 --- a/README.md +++ b/README.md @@ -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. ``` diff --git a/gtm-plugin.fish b/gtm-plugin.fish new file mode 100755 index 0000000..1f68317 --- /dev/null +++ b/gtm-plugin.fish @@ -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