File: bash-completion.sh

package info (click to toggle)
cod-tools 2.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 114,852 kB
  • sloc: perl: 53,336; sh: 23,842; ansic: 6,318; xml: 1,982; yacc: 1,112; makefile: 716; python: 158; sql: 73
file content (34 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#*
#  This file sets up (when source'd) the bash completion for common
#  programs from cod-tools.
#
#  The completion is based on the command line options, listed by issuing
#  a program with '--help' option.
#
#**
function _cod_tools_completion
{
    case "${COMP_WORDS[COMP_CWORD]}" in
        -*)
            COMPREPLY=( $(compgen -W "$($1 --help \
                    | grep -P '^\s*-' \
                    | perl -lpe 's/^\s+//; s/\s*,\s*/\n/g' \
                    | awk '{print $1}' \
                    | sort )" -- ${COMP_WORDS[COMP_CWORD]}) )
            # Always add a space after each command
            for ((i=0; i < ${#COMPREPLY[@]}; i++)); do
                COMPREPLY[$i]="${COMPREPLY[$i]} "
            done
            ;;
        *)
            COMPREPLY=()
    esac
}
complete -o nospace -o default -F _cod_tools_completion cif_cod_check
complete -o nospace -o default -F _cod_tools_completion cif_cod_deposit
complete -o nospace -o default -F _cod_tools_completion cif_fix_values
complete -o nospace -o default -F _cod_tools_completion cif_filter
complete -o nospace -o default -F _cod_tools_completion cif_mark_disorder
complete -o nospace -o default -F _cod_tools_completion cif_molecule
complete -o nospace -o default -F _cod_tools_completion cif_tcod_tree
complete -o nospace -o default -F _cod_tools_completion cif_values