From 1d28202f1773fc2b1580da16c038b4487697cc3b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 5 Feb 2020 23:52:23 +0100 Subject: [PATCH] Add styler zsh completions Can list available commands, specific options for commands (such as list), and a complete list of installed themes that can be applied. --- styler/.config/zsh/completions/_styler | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 styler/.config/zsh/completions/_styler diff --git a/styler/.config/zsh/completions/_styler b/styler/.config/zsh/completions/_styler new file mode 100755 index 0000000..53edded --- /dev/null +++ b/styler/.config/zsh/completions/_styler @@ -0,0 +1,50 @@ +#compdef styler +# the above line should contain all commands to be completed using this file +# zsh autocompletions for styler script + +local curcontext="$curcontext" state line ret=1 +local cmdnames=(theme set download list help version) + +_arguments -C \ + '1: :->cmds' \ + '2: :->args' \ + '3: :->subrout' && ret=0 + +local -a initial_commands=( + 'theme:Temporarily switch theme to specified argument' + 'set:Permanently set theme to specified argument' + 'download:Download a base16 compatible template' + 'list:Display installed processors, templates, or themes' + 'help:Display help text and exit' + 'version:Display styler information and exit' +) + +__themes() { + echo "$(styler list themes)" +} + +case $state in +cmds) + _describe -t commands 'styler cmd' initial_commands && ret=0 + ;; + +args) + case $words[2] in + theme | set) + _values 'themes' $(__themes) && ret=0 + ;; + + list) + _values 'listopts' \ + 'processors[Display available application processors]' \ + 'templates[Display available base16 templates]' \ + 'themes[Display available base16 themes]' && ret=0 + ;; + + *) + ((ret)) && _message 'no more arguments' + ;; + + esac + ;; +esac