1 # nmh completion for bash
2 # Copyright 2003 "Wade Richards" <wade@wabyn.net>
3 # Permission granted to redistribute under the BSD license
5 [ "$BASH_COMPLETION" ] || echo "ERROR: COMPLETION-BASH is not intended to be \
6 sourced directly, but rather added to a bash-completion package installation."
11 # args: command comp-word prev-word
12 local command current prev folder origfolder i orig_opts
15 current=${COMP_WORDS[COMP_CWORD]}
16 prev=${COMP_WORDS[COMP_CWORD-1]}
19 orig_opts=$(shopt -p extglob)
22 # Get the folder, if specified
23 for (( i=0; i < ${#COMP_WORDS}-1; i++ ))
25 case "${COMP_WORDS[i]}" in
27 folder=${COMP_WORDS[i]}
28 origfolder=$( folder -f )
35 # Command-line switches for the most common commands.
38 # no sequences or messages
39 options=(-alias -list -nolist -normalize -nonormalize -user
40 -nouser -Version -help)
43 options=(-inplace -noinplace -quiet -noquiet -verbose
44 -noverbose -Version -help)
47 options=(-form -use -nouse
48 -editor -noedit -whatnowproc
52 options=(-sequence -all -noall -showzero -noshowzero
53 -recurse -norecurse -fast -nofast -alpha -noalpha -Version
57 options=(-all -noall -create -nocreate -fast -nofast -header
58 -noheader -recurse -norecurse -total -nototal -list -nolist
59 -push -pop -pack -nopack -print -verbose -noverbose
63 options=(-annotate -noannotate -form
64 -editor -noedit -whatnowproc -build
68 options=(-audit -noaudit -changecur -nochangecur -form
69 -file -silent -nosilent -truncate -notruncate -width
73 options=(-sequence -add -delete -list -public -nopublic
74 -zero -nozero -Version -help)
77 options=(-file -Version -help)
80 options=(-and -or -not -lbrace -rbrace --component -cc
81 -date -from -search -subject -to -after -before -datefield
82 -sequence -public -nopublic -zero -nozero -list -nolist
86 options=(-link -nolink -src -file -Version -help)
89 options=(-annotate -noannotate -group -nogroup -cc
90 -nocc -query -noquery -form -filter -nofilter
91 -mime -nomime -editor -noedit -whatnowproc
92 -build -file -Version -help)
95 options=(-interactive -nointeractive -Version -help)
98 options=(-link -nolink -Version -help)
101 options=(-form -header -noheader
102 -width -file -Version -help )
107 options=(-file -part -type -form -Version -help)
110 options=(-datefield -textfield -notextfield -limit -nolimit
111 -verbose -noverbose -Version -help)
114 options=(-help -Version -seq)
121 options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
126 start=${current/%-*/}
127 options=( $( scan $folder -form "=%(msg)" "${start}-last" ) first prev cur next last )
128 options=( ${options[@]//#/${start}-} )
132 # Message number, or start of range
133 options=( $( scan $folder -form "=%(msg)" ) first prev cur next last )
134 options=( ${options[@]} ${options[@]//%/-} )
138 # special message aliases
139 options=( first prev cur next last unseen )
142 # What about sequences? I can't quite see how to get the list of possible sequences, so I
143 # guess the user will have to type them in the old-fashioned way.
149 COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
152 [ "$have" ] && complete -F _nmh ali anno burst comp dist flist flists folder folders forw inc mark mhbuild mhl mhlist mhmail mhparam mhpath mhstore next packf pick prev prompter rcvdist rcvpack rcvstore refile repl rmf rmm scan send sendfiles show slocal sortm whatnow