1 # nmh completion for bash
2 # Copyright 2003 "Wade Richards" <wade@wabyn.net>
3 # Permission granted to redistribute under the BSD license
8 # args: command comp-word prev-word
9 local command current prev folder origfolder i orig_opts
12 current=${COMP_WORDS[COMP_CWORD]}
13 prev=${COMP_WORDS[COMP_CWORD-1]}
16 orig_opts=$(shopt -p extglob)
19 # Get the folder, if specified
20 for (( i=0; i < ${#COMP_WORDS}-1; i++ ))
22 case "${COMP_WORDS[i]}" in
24 folder=${COMP_WORDS[i]}
25 origfolder=$( folder -f )
32 # Command-line switches for the most common commands.
35 # no sequences or messages
36 options=(-alias -list -nolist -normalize -nonormalize -user
37 -nouser -version -help)
40 options=(-inplace -noinplace -quiet -noquiet -verbose
41 -noverbose -version -help)
44 options=(-form -use -nouse
45 -editor -noedit -whatnowproc -nowhatnowproc
49 options=(-sequence -all -noall -showzero -noshowzero
50 -recurse -norecurse -fast -nofast -alpha -noalpha -version
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
60 options=(-annotate -noannotate -form
61 -editor -noedit -whatnowproc
66 options=(-audit -noaudit -changecur -nochangecur -form
67 -file -silent -nosilent -truncate -notruncate -width
71 options=(-sequence -add -delete -list -public -nopublic
72 -zero -nozero -version -help)
75 options=(-showmimeproc -header -noheader -checkmime
76 -nocheckmime -version -help)
79 options=(-file -version -help)
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
88 options=(-showproc -showmimeproc -header -noheader -checkmime
89 -nocheckmime -version -help)
92 options=(-link -nolink -preserve -nopreserve -unlink
93 -nounlink -src -file -rmmproc -normmproc -version -help)
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)
102 options=(-interactive -nointeractive -version -help)
105 options=(-link -nolink -version -help)
108 options=(-form -header -noheader
109 -width -file -version -help )
112 options=(-showproc -showmimeproc -header -noheader
113 -checkmime -nocheckmime -version -help)
116 options=(-datefield -textfield -notextfield -limit -nolimit
117 -verbose -noverbose -version -help)
120 options=(-help -version -seq)
127 options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
132 start=${current/%-*/}
133 options=( $( scan $folder -form "=%(msg)" "${start}-last" ) first prev cur next last )
134 options=( ${options[@]//#/${start}-} )
138 # Message number, or start of range
139 options=( $( scan $folder -form "=%(msg)" ) first prev cur next last )
140 options=( ${options[@]} ${options[@]//%/-} )
144 # special message aliases
145 options=( first prev cur next last unseen )
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.
155 COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
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