PageRenderTime 49ms CodeModel.GetById 45ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/complete/getent

http://github.com/brinkman83/bashrc
#! | 46 lines | 38 code | 8 blank | 0 comment | 0 complexity | af53e228da54e547e7462c45c3769283 MD5 | raw file
 1# getent(1) completion
 2
 3
 4comp_include _get_cword
 5
 6
 7_getent()
 8{
 9    local cur prev
10
11    COMPREPLY=()
12    cur=`_get_cword`
13    prev=${COMP_WORDS[COMP_CWORD-1]}
14
15    case $prev in
16        passwd)
17            COMPREPLY=( $( compgen -u $cur  ) )
18            return 0
19            ;;
20        group)
21            COMPREPLY=( $( compgen -g $cur  ) )
22            return 0
23            ;;
24        services)
25            COMPREPLY=( $( compgen -s $cur  ) )
26            return 0
27            ;;
28        hosts)
29            COMPREPLY=( $( compgen -A hostname $cur  ) )
30            return 0
31            ;;
32        protocols)
33            COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) )
34            return 0
35            ;;
36        networks)
37            COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) )
38            return 0
39            ;;
40    esac
41
42
43    if [ $COMP_CWORD -eq 1 ]; then
44        COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) )
45    fi
46} # _getent()