]> rtime.felk.cvut.cz Git - notmuch.git/blob - completion/notmuch-completion.zsh
cli: address: Add --filter-by option to configure address filtering
[notmuch.git] / 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 count))' \
65     '--filter-by=[filter out duplicate addresses]:filter-by:((nameaddr\:"both name and address part" name\:"name part" addr\:"address part" addrfold\:"case-insensitive address part" nameaddrfold\:"name and case-insensitive address part"))'
66 }
67
68 _notmuch()
69 {
70   if (( CURRENT > 2 )) ; then
71     local cmd=${words[2]}
72     curcontext="${curcontext%:*:*}:notmuch-$cmd"
73     (( CURRENT-- ))
74     shift words
75     _call_function ret _notmuch_$cmd
76     return ret
77   else
78     _notmuch_commands
79   fi
80 }
81
82 _notmuch "$@"
83
84 # vim: set sw=2 sts=2 ts=2 et ft=zsh :