From fcfaf390814678414f3391840fe97881466e4380 Mon Sep 17 00:00:00 2001 From: James Walker Date: Tue, 7 Apr 2015 22:37:02 -0400 Subject: [PATCH] timetrap plugin --- home/.zsh/custom/plugins/timetrap/_t | 31 +++++++++++++++++++ .../plugins/timetrap/timetrap.plugin.zsh | 0 2 files changed, 31 insertions(+) create mode 100644 home/.zsh/custom/plugins/timetrap/_t create mode 100644 home/.zsh/custom/plugins/timetrap/timetrap.plugin.zsh diff --git a/home/.zsh/custom/plugins/timetrap/_t b/home/.zsh/custom/plugins/timetrap/_t new file mode 100644 index 0000000..14092f9 --- /dev/null +++ b/home/.zsh/custom/plugins/timetrap/_t @@ -0,0 +1,31 @@ +#compdef t + +_t() { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments \ + '1: :->t_command'\ + '2: :->first_arg' + + case $state in + t_command) + compadd "$@" archive backend configure display edit in kill\ + list now out resume sheet week month + ;; + + first_arg) + # If the first argument starts with s or d (sheet or display), + # the second argument can be autocompleted to one of the existing + # non-archived sheets. + if [[ $words[2] == s* || $words[2] == d* ]]; then + query='SELECT DISTINCT(sheet) FROM entries WHERE sheet NOT LIKE "\_%" ESCAPE "\";' + echo $query | t b | while read sheet; do + compadd "$@" $sheet + done + fi + ;; + esac +} + +_t "$@" diff --git a/home/.zsh/custom/plugins/timetrap/timetrap.plugin.zsh b/home/.zsh/custom/plugins/timetrap/timetrap.plugin.zsh new file mode 100644 index 0000000..e69de29