]>
diplodocus.org Git - nmh/blob - etc/bash_completion_nmh-gen
3 # Generates COMPLETION-BASH from man/mh-chart.man.
5 # This code is Copyright (c) 2016, by the authors of nmh.
6 # See the COPYRIGHT file in the root directory of the nmh
7 # distribution for complete copyright information.
9 mhchart
=man
/mh
-chart.man
11 #### Extract switches for nmh program.
15 #### Extract lines from just after .B program-name to just before
16 #### blank line, and then only those that start with .RB, e.g.,
17 #### .RB [ \-list " | " \-nolist ]
18 #### .RB " | " \-autoheaderencoding ]
19 #### .RB [ \-\|\-component
20 awk '/^.B.*(\/| )'"$program"'/,/^$/ {
24 sed -e 's/\.RB //g' -e 's/\[//g' -e 's/\]//g' \
25 -e 's/\(\\\)*//g' -e 's/-|-/-/g' -e 's/" *| "//g' \
26 -e 's/^ *//' -e 's/ *$//' -e 's/ */ /g'
30 # bash completions for nmh commands -*- shell-script -*-
31 # This file was generated by COMPLETION-BASH-gen.
33 # This code is Copyright (c) 2016, by the authors of nmh.
34 # See the COPYRIGHT file in the root directory of the nmh
35 # distribution for complete copyright information.
37 # To use: source at a bash prompt or in an initialization file.
44 case ${COMP_WORDS[COMP_CWORD]} in
48 #### Extract program names from lines such as:
49 #### .B %nmhlibexecdir%/install\-mh
50 #### .B new \-mode fnext
51 programs
=`egrep '\.B [^\-]' "$mhchart" | \
52 sed -e 's/^\.B //' -e 's/ .*//' -e 's|%[^%]*%/||' -e 's/\\-/-/'`
53 for program
in $programs; do
54 switches
=`prog_switches "$program"`
55 # Support mime as alias for mhbuild.
56 [ "$program" = mhbuild
] && program
='mhbuild|mime'
57 printf ' %s) switches=(%s) ;;\n' "$program" "$switches"
60 programs
="$programs mime"
65 +*) switches=($(folder -all -fast -recurse | sed 's/^/+/')) ;;
67 [flc.np]*) switches=(first last cur . next prev) ;;
71 [ $1 = mhpath ] && switches=("${switches[*]}" + new)
73 COMPREPLY=($(compgen -W "${switches[*]}" -- ${COMP_WORDS[COMP_CWORD]}))
78 #### There better not be an nmh program name with whitespace in it.
79 echo complete
-F _nmh
$programs