PageRenderTime 118ms CodeModel.GetById 116ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/complete/wvdial

http://github.com/brinkman83/bashrc
#! | 49 lines | 40 code | 9 blank | 0 comment | 0 complexity | fec91da11cf27da14be9e3050f192e63 MD5 | raw file
 1# wvdial(1) completion
 2
 3
 4comp_include _filedir _get_cword
 5
 6
 7_wvdial()
 8{
 9    local cur prev config i IFS=$'\t\n'
10
11    COMPREPLY=()
12    cur=`_get_cword`
13    prev=${COMP_WORDS[COMP_CWORD-1]}
14
15    case $prev in
16        --config)
17            _filedir
18            return 0
19            ;;
20    esac
21
22    case $cur in
23        -*)
24            COMPREPLY=( $( compgen -W '--config --chat \
25                --remotename --help --version --no-syslog' \
26                -- $cur ) )
27            ;;
28        *)
29            # start with global and personal config files
30                config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
31            # replace with command line config file if present
32            for (( i=1; i < COMP_CWORD; i++ )); do
33                if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
34                    config=${COMP_WORDS[i+1]}
35                    break
36                fi
37            done
38            # parse config files for sections and
39            # remove default section
40            COMPREPLY=( $( sed -ne \
41                    "s|^\[Dialer \($cur.*\)\]$|\1|p" \
42                    $config 2>/dev/null |grep -v '^Defaults$'))
43            # escape spaces
44            COMPREPLY=${COMPREPLY// /\\ }
45            ;;
46    esac
47} # _wvdial()
48
49