]> git.notmuchmail.org Git - notmuch/blob - completion/notmuch-completion.zsh
Merge tag '0.18.2_rc1'
[notmuch] / completion / notmuch-completion.zsh
1 #compdef notmuch
2
3 # ZSH completion for `notmuch`
4 # Copyright © 2009 Ingmar Vanhassel <ingmar@exherbo.org>
5
6 _notmuch_commands()
7 {
8   local -a notmuch_commands
9   notmuch_commands=(
10     'setup:interactively set up notmuch for first use'
11     'new:find and import any new message to the database'
12     'search:search for messages matching the search terms, display matching threads as results'
13     'reply:constructs a reply template for a set of messages'
14     'show:show all messages matching the search terms'
15     'tag:add or remove tags for all messages matching the search terms'
16     'dump:creates a plain-text dump of the tags of each message'
17     'restore:restores the tags from the given file'
18     'help:show details on a command'
19   )
20
21   _describe -t command 'command' notmuch_commands
22 }
23
24 _notmuch_dump()
25 {
26   _files
27 }
28
29 _notmuch_help_topics()
30 {
31   local -a notmuch_help_topics
32   notmuch_help_topics=(
33     'search-terms:show common search-terms syntax'
34   )
35   _describe -t notmuch-help-topics 'topic' notmuch_help_topics
36 }
37
38 _notmuch_help()
39 {
40   _alternative \
41     _notmuch_commands \
42     _notmuch_help_topics
43 }
44
45 _notmuch_restore()
46 {
47   _files
48 }
49
50 _notmuch_search()
51 {
52   _arguments -s : \
53     '--max-threads=[display only the first x threads from the search results]:number of threads to show: ' \
54     '--first=[omit the first x threads from the search results]:number of threads to omit: ' \
55     '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))'
56 }
57
58 _notmuch()
59 {
60   if (( CURRENT > 2 )) ; then
61     local cmd=${words[2]}
62     curcontext="${curcontext%:*:*}:notmuch-$cmd"
63     (( CURRENT-- ))
64     shift words
65     _call_function ret _notmuch_$cmd
66     return ret
67   else
68     _notmuch_commands
69   fi
70 }
71
72 _notmuch "$@"
73
74 # vim: set sw=2 sts=2 ts=2 et ft=zsh :