add zsh completion

This commit is contained in:
Abraham Toriz 2022-11-04 22:00:41 -06:00
parent cfb2989853
commit 9433903cdf
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
1 changed files with 30 additions and 0 deletions

30
completions/zsh/_t Normal file
View File

@ -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 "$@"