]> git.notmuchmail.org Git - notmuch/blob - completion/notmuch-completion.zsh
Merge branch 'release'
[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     'help:display documentation for a subcommand'
11     'setup:interactively configure notmuch'
12
13     'address:output addresses from matching messages'
14     'compact:compact the notmuch database'
15     'config:access notmuch configuration file'
16     'count:count messages matching the given search terms'
17     'dump:creates a plain-text dump of the tags of each message'
18     'insert:add a message to the maildir and notmuch database'
19     'new:incorporate new mail into the notmuch database'
20     'reply:constructs a reply template for a set of messages'
21     'restore:restores the tags from the given file (see notmuch dump)'
22     'search:search for messages matching the given search terms'
23     'show:show messages matching the given search terms'
24     'tag:add/remove tags for all messages matching the search terms'
25   )
26
27   _describe -t command 'command' notmuch_commands
28 }
29
30 _notmuch_dump()
31 {
32   _files
33 }
34
35 _notmuch_help_topics()
36 {
37   local -a notmuch_help_topics
38   notmuch_help_topics=(
39     'search-terms:show common search-terms syntax'
40   )
41   _describe -t notmuch-help-topics 'topic' notmuch_help_topics
42 }
43
44 _notmuch_help()
45 {
46   _alternative \
47     _notmuch_commands \
48     _notmuch_help_topics
49 }
50
51 _notmuch_restore()
52 {
53   _files
54 }
55
56 _notmuch_search()
57 {
58   _arguments -s : \
59     '--max-threads=[display only the first x threads from the search results]:number of threads to show: ' \
60     '--first=[omit the first x threads from the search results]:number of threads to omit: ' \
61     '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \
62     '--output=[select what to output]:output:((summary threads messages files tags))'
63 }
64
65 _notmuch_address()
66 {
67   _arguments -s : \
68     '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \
69     '--output=[select what to output]:output:((sender recipients count))'
70 }
71
72 _notmuch()
73 {
74   if (( CURRENT > 2 )) ; then
75     local cmd=${words[2]}
76     curcontext="${curcontext%:*:*}:notmuch-$cmd"
77     (( CURRENT-- ))
78     shift words
79     _call_function ret _notmuch_$cmd
80     return ret
81   else
82     _notmuch_commands
83   fi
84 }
85
86 _notmuch "$@"
87
88 # vim: set sw=2 sts=2 ts=2 et ft=zsh :