PageRenderTime 15ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/bash_completion_lib/include/_longopt

http://github.com/brinkman83/bashrc
#! | 29 lines | 24 code | 5 blank | 0 comment | 0 complexity | 03becb8469cfbf19f57a3c4a99eee3b6 MD5 | raw file
 1comp_include _filedir _get_cword
 2
 3
 4_longopt()
 5{
 6    local cur opt
 7
 8    cur=`_get_cword`
 9
10    if [[ "$cur" == --*=* ]]; then
11        opt=${cur%%=*}
12        # cut backslash that gets inserted before '=' sign
13        opt=${opt%\\*}
14        cur=${cur#*=}
15        _filedir
16        COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
17        return 0
18    fi
19
20    if [[ "$cur" == -* ]]; then
21        COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
22                -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
23                   command grep "^$cur" | sort -u ) )
24    elif [[ "$1" == @(mk|rm)dir ]]; then
25        _filedir -d
26    else
27        _filedir
28    fi
29}