summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2016-04-05 22:34:55 +0200
committerLucas Hoffmann <l-m-h@web.de>2016-07-14 12:26:41 +0200
commit868eca4681346ed255ff46aa8fd226aadeac0fc6 (patch)
tree230640d06eb93274bee5035fe3394b6a9408bff3 /extra
parent98f1ba44cab6a8fdf0a50c45e795792f2d775a61 (diff)
Add global options to zsh completion
Diffstat (limited to 'extra')
-rw-r--r--extra/completion/alot-completion.zsh41
1 files changed, 30 insertions, 11 deletions
diff --git a/extra/completion/alot-completion.zsh b/extra/completion/alot-completion.zsh
index 2f2da2a3..2d57d8e1 100644
--- a/extra/completion/alot-completion.zsh
+++ b/extra/completion/alot-completion.zsh
@@ -35,18 +35,37 @@ _alot_compose()
_alot()
{
- if (( CURRENT > 2 )) ; then
- local cmd=${words[2]}
- curcontext="${curcontext%:*:*}:alot-$cmd"
- (( CURRENT-- ))
- shift words
- _call_function ret _alot_$cmd
- return ret
- else
- _alot_subcommands
- fi
+ local state
+ local ret=1
+ # Complete global options. Set $state to "command" or "options" in order to
+ # do further completion.
+ _arguments \
+ '(- *)--help[show the help message]' \
+ '(- *)--version[show version information]' \
+ '(--help --version -r --read-only)'-{r,-read-only}'[open db in read only mode]' \
+ '(--help --version -c --config)'-{c,-config}'[specify an alternative config file]:alot config file:_files' \
+ '(--help --version -n --notmuch-config)'-{n,-notmuch-config}'[specify an alternative notmuch config file]:notmuch config file:_files' \
+ '(--help --version -C --colour-mode)'-{C,-colour-mode}'[terminal colour mode]:colour mode:(1 16 256)' \
+ '(--help --version -p --mailindex-path)'-{p,-mailindex-path}'[path to notmuch index]:directory:_directories' \
+ '(--help --version -d --debug-level)'-{d,-debug-level}'[set the log level]:debug level:(debug info warning error)' \
+ '(--help --version -l --logfile)'-{l,-logfile}'[specify the logfile (default: /dev/null)]:log file:_files' \
+ ': :->command' \
+ '*:: :->options' \
+ && ret=0
+
+ case $state in
+ command)
+ _alot_subcommands
+ ;;
+ options)
+ # Call the specific completion function for the subcommand.
+ _call_function ret _alot_$words[1]
+ ;;
+ esac
+
+ return ret
}
-_alot "$@"
+_alot $@
# vim: set sw=2 sts=2 ts=2 et ft=zsh :