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 -file
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 -version
60 options=(-annotate -noannotate -form -format -noformat
61 -filter -inplace -noinplace -mime -nomime
62 -editor -noedit -whatnowproc
63 -nowhatnowproc -build -file
67 options=(-audit -noaudit -changecur -nochangecur -form -format
68 -file -silent -nosilent -truncate -notruncate -width
72 options=(-sequence -add -delete -list -public -nopublic
73 -zero -nozero -version -help)
76 options=(-showmimeproc -header -noheader -checkmime
77 -nocheckmime -version -help)
80 options=(-file -mbox -mmdf -version -help)
83 options=(-and -or -not -lbrace -rbrace --component -cc
84 -date -from -search -subject -to -after -before -datefield
85 -sequence -public -nopublic -zero -nozero -list -nolist
89 options=(-showproc -showmimeproc -header -noheader -checkmime
90 -nocheckmime -version -help)
93 options=(-draft -link -nolink -preserve -nopreserve -unlink
94 -nounlink -src -file -rmmproc -normmproc -version -help)
97 options=(-annotate -noannotate -group -nogroup -cc
98 -nocc -query -noquery -form -format -noformat -filter
99 -inplace -noinplace -mime -nomime -fcc -width
100 -editor -noedit -whatnowproc
101 -nowhatnowproc -build -file -version -help)
104 options=(-interactive -nointeractive -version -help)
107 options=(-link -nolink -version -help)
110 options=(-clear -noclear -form -format -header -noheader
111 -width -file -version -help )
114 options=(-draft -showproc -showmimeproc -header -noheader
115 -checkmime -nocheckmime -version -help)
118 options=(-datefield -textfield -notextfield -limit -nolimit
119 -verbose -noverbose -version -help)
122 options=(-help -version -seq)
129 options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
134 start=${current/%-*/}
135 options=( $( scan $folder -format "%(msg)" "${start}-last" ) first prev cur next last )
136 options=( ${options[@]//#/${start}-} )
140 # Message number, or start of range
141 options=( $( scan $folder -format "%(msg)" ) first prev cur next last )
142 options=( ${options[@]} ${options[@]//%/-} )
146 # special message aliases
147 options=( first prev cur next last unseen )
150 # What about sequences? I can't quite see how to get the list of possible sequences, so I
151 # guess the user will have to type them in the old-fashioned way.
157 COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
160 [ "$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 rcvtty refile repl rmf rmm scan send sendfiles show slocal sortm whatnow