From 9433903cdfd01b28d2abbeee4e197c18f0f3962c Mon Sep 17 00:00:00 2001 From: Abraham Toriz Date: Fri, 4 Nov 2022 22:00:41 -0600 Subject: [PATCH] add zsh completion --- completions/zsh/_t | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 completions/zsh/_t diff --git a/completions/zsh/_t b/completions/zsh/_t new file mode 100644 index 0000000..d6c3f49 --- /dev/null +++ b/completions/zsh/_t @@ -0,0 +1,30 @@ +#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 + t l --all --flat | while read sheet; do + compadd "$@" $sheet + done + fi + ;; + esac +} + +_t "$@"