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 -draftfolder -draftmessage
45 -nodraftfolder -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 -draftfolder
62 -draftmessage -nodraftfolder -editor -noedit -whatnowproc
63 -nowhatnowproc -dashstuffing -nodashstuffing -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 -draftfolder
100 -draftmessage -nodraftfolder -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 -reverse -noreverse -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=(-alias -check -nocheck -draft -draftfolder
123 -draftmessage -nodraftfolder -version -help)
126 options=(-help -version -seq)
133 options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
138 start=${current/%-*/}
139 options=( $( scan $folder -format "%(msg)" "${start}-last" ) first prev cur next last )
140 options=( ${options[@]//#/${start}-} )
144 # Message number, or start of range
145 options=( $( scan $folder -format "%(msg)" ) first prev cur next last )
146 options=( ${options[@]} ${options[@]//%/-} )
150 # special message aliases
151 options=( first prev cur next last unseen )
154 # What about sequences? I can't quite see how to get the list of possible sequences, so I
155 # guess the user will have to type them in the old-fashioned way.
161 COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
164 [ "$have" ] && complete -F _nmh ali anno burst comp dist flist flists folder folders forw inc mark mhbuild mhl mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk msh next packf pick prev prompter rcvdist rcvpack rcvstore rcvtty refile repl rmf rmm scan send sendfiles show slocal sortm whatnow whom