Updated shell completion files to recent changes in the programs.
[mmh] / docs / COMPLETION-BASH
1 # nmh completion for bash
2 # Copyright 2003 "Wade Richards" <wade@wabyn.net>
3 # Permission granted to redistribute under the BSD license
4
5 have show &&
6 _nmh()
7 {
8     # args: command comp-word prev-word
9     local command current prev folder origfolder i orig_opts
10
11     COMPREPLY=()
12     current=${COMP_WORDS[COMP_CWORD]}
13     prev=${COMP_WORDS[COMP_CWORD-1]}
14     command=$1
15
16     orig_opts=$(shopt -p extglob)
17     shopt -s extglob
18
19     # Get the folder, if specified
20     for (( i=0; i < ${#COMP_WORDS}-1; i++ ))
21     do
22         case "${COMP_WORDS[i]}" in
23         \++([a-zA-Z_]) )
24             folder=${COMP_WORDS[i]}
25             origfolder=$( folder -f )
26             ;;
27         esac
28     done
29
30     case $current in
31     -* )
32         # Command-line switches for the most common commands.
33         case $command in
34         ali )
35             # no sequences or messages
36             options=(-alias -list -nolist -normalize -nonormalize -user
37                     -nouser -version -help)
38             ;;
39         burst )
40             options=(-inplace -noinplace -quiet -noquiet -verbose
41                     -noverbose -version -help)
42             ;;
43         comp )
44             options=(-form -use -nouse
45                     -editor -noedit -whatnowproc -nowhatnowproc
46                     -version -help )
47            ;;
48         flist* )
49             options=(-sequence -all -noall -showzero -noshowzero
50                     -recurse -norecurse -fast -nofast -alpha -noalpha -version
51                     -help)
52             ;;
53         folder* )
54             options=(-all -noall -create -nocreate -fast -nofast -header
55                     -noheader -recurse -norecurse -total -nototal -list -nolist
56                     -push -pop -pack -nopack -print -verbose -noverbose
57                     -version -help)
58             ;;
59         forw )
60             options=(-annotate -noannotate -form
61                     -editor -noedit -whatnowproc
62                     -nowhatnowproc -build
63                     -version -help)
64             ;;
65         inc )
66             options=(-audit -noaudit -changecur -nochangecur -form
67                     -file -silent -nosilent -truncate -notruncate -width
68                     -version -help)
69             ;;
70         mark )
71             options=(-sequence -add -delete -list -public -nopublic
72                     -zero -nozero -version -help)
73             ;;
74         next )
75             options=(-showmimeproc -header -noheader -checkmime
76                     -nocheckmime -version -help)
77             ;;
78         packf )
79             options=(-file -version -help)
80             ;;
81         pick )
82             options=(-and -or -not -lbrace -rbrace --component -cc
83                     -date -from -search -subject -to -after -before -datefield
84                     -sequence -public -nopublic -zero -nozero -list -nolist
85                     -version -help)
86             ;;
87         prev )
88             options=(-showproc -showmimeproc -header -noheader -checkmime
89                     -nocheckmime -version -help)
90             ;;
91         refile )
92             options=(-link -nolink -preserve -nopreserve -unlink
93                     -nounlink -src -file -rmmproc -normmproc -version -help)
94             ;;
95         repl )
96             options=(-annotate -noannotate -group -nogroup -cc
97                     -nocc -query -noquery -form -filter -nofilter
98                     -mime -nomime -editor -noedit -whatnowproc
99                     -nowhatnowproc -build -file -version -help)
100             ;;
101         rmf )
102             options=(-interactive -nointeractive -version -help)
103             ;;
104         rmm )
105             options=(-link -nolink -version -help)
106             ;;
107         scan )
108             options=(-clear -noclear -form -header -noheader
109                     -width -file -version -help )
110             ;;
111         show )
112             options=(-showproc -showmimeproc -header -noheader
113                     -checkmime -nocheckmime -version -help)
114             ;;
115         sortm )
116             options=(-datefield -textfield -notextfield -limit -nolimit
117                     -verbose -noverbose -version -help)
118             ;;
119         * )
120             options=(-help -version -seq)
121             ;;
122         esac
123         ;;
124
125     +* )
126         # Folders
127         options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
128         ;;
129
130     +([0-9a-z])-* )
131         # Partial range
132         start=${current/%-*/}
133         options=( $( scan $folder -form "=%(msg)" "${start}-last" ) first prev cur next last )
134         options=( ${options[@]//#/${start}-} )
135         ;;
136
137     +([0-9]) )
138         # Message number, or start of range
139         options=( $( scan $folder -form "=%(msg)" ) first prev cur next last )
140         options=( ${options[@]} ${options[@]//%/-} )
141         ;;
142
143     [fpcnlu]* )
144         # special message aliases
145         options=( first prev cur next last unseen )
146         ;;
147
148         # What about sequences?  I can't quite see how to get the list of possible sequences, so I
149         # guess the user will have to type them in the old-fashioned way.
150
151     esac
152
153     eval $orig_opts
154
155     COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
156     return 0
157 }
158 [ "$have" ] && complete -F _nmh ali anno burst comp dist flist flists folder folders forw inc mark mhbuild mhl mhlist mhmail mhparam mhpath mhshow mhstore msgchk next packf pick prev prompter rcvdist rcvpack rcvstore refile repl rmf rmm scan send sendfiles show slocal sortm whatnow