PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/complete -o filenames -o nospace/perl

http://github.com/brinkman83/bashrc
#! | 45 lines | 38 code | 7 blank | 0 comment | 0 complexity | d245099e90e6a56966dd525625cec0a5 MD5 | raw file
 1comp_include _filedir _get_cword _perlmodules
 2
 3
 4_perl()
 5{
 6    local cur optPrefix optSuffix prev prefix temp
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10    prev=${COMP_WORDS[COMP_CWORD-1]}
11    prefix=""
12
13    # If option not followed by whitespace, reassign prev and cur
14    if [[ "$cur" == -?* ]]; then
15	temp=$cur
16	prev=${temp:0:2}
17	cur=${temp:2}
18	optPrefix=-P$prev
19	optSuffix=-S/
20	prefix=$prev
21    fi
22
23    case "$prev" in
24    -I|-x)
25	local IFS=$'\t\n' 
26        COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) )
27        return 0
28        ;;
29    -m|-M)
30        _perlmodules
31        return 0
32        ;;
33    esac
34
35    # handle case where first parameter is not a dash option
36    if [[ "`_get_cword`" != -* ]]; then
37	_filedir
38	return 0
39    fi
40
41    # complete using basic options
42    COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
43            -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
44    return 0
45} # _perl()