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

/bash_completion_lib/complete/complete

http://github.com/brinkman83/bashrc
#! | 55 lines | 47 code | 8 blank | 0 comment | 0 complexity | d35c01bd5219eabffeb6dce439f46ef7 MD5 | raw file
 1comp_include _get_cword
 2
 3
 4_complete()
 5{
 6    local cur prev options
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10    prev=${COMP_WORDS[COMP_CWORD-1]}
11
12    case $prev in
13        -o)
14            options="default dirnames filenames"
15            [ -n "$bash205b" ] && options="$options nospace"
16            [ -n "$bash3" ] && options="$options bashdefault plusdirs"
17            COMPREPLY=( $( compgen -W "$options" -- $cur ) )
18            return 0
19            ;;
20
21        -A)
22            COMPREPLY=( $( compgen -W 'alias arrayvar binding \
23                builtin command directory disabled enabled \
24                export file function group helptopic hostname \
25                job keyword running service setopt shopt \
26                signal stopped user variable' -- $cur ) )
27            return 0
28            ;;
29
30        -C)
31            COMPREPLY=( $( compgen -A command -- $cur ) )
32            return 0
33            ;;
34        -F)
35            COMPREPLY=( $( compgen -A function -- $cur ) )
36            return 0
37            ;;
38        -@(p|r))
39            COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
40                    grep "^$cur" ) )
41            return 0
42            ;;
43
44    esac
45
46    if [[ "$cur" == -* ]]; then
47        # relevant options completion
48        options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
49        [ -n "$bash205" ] && options="$options -o"
50        COMPREPLY=( $( compgen -W "$options" -- $cur ) )
51    else
52        COMPREPLY=( $( compgen -A command -- $cur ) )
53    fi
54}
55_complete