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