Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
59 - 1
# bash alias completion
2
#
3
_alias()
4
{
5
    local cur
6
 
7
    COMPREPLY=()
8
    _get_comp_words_by_ref cur
9
 
10
    case $COMP_LINE in
11
        *[^=])
12
            COMPREPLY=( $( compgen -A alias -- "$cur" ) )
13
            ;;
14
        *=)
15
            COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | sed \
16
                -e 's|^alias '"$cur"'\(.*\)$|\1|' )" )
17
            ;;
18
    esac
19
}
20
complete -F _alias -o nospace alias
21
 
22
# bash export completion
23
#
24
_export()
25
{
26
    local cur
27
 
28
    COMPREPLY=()
29
    _get_comp_words_by_ref cur
30
 
31
    case $COMP_LINE in
32
        *=\$*)
33
            COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) )
34
            ;;
35
        *[^=])
36
            COMPREPLY=( $( compgen -v -S '=' -- "$cur" ) )
37
            ;;
38
        *=)
39
            COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
40
                ( echo -n \'
41
                  sed -e 's/'\''/'\''\\\'\'''\''/g'
42
                  echo -n \' ) )" )
43
            ;;
44
    esac
45
}
46
complete -F _export -o default -o nospace export
47
 
48
# bash shell function completion
49
#
50
_function()
51
{
52
    local cur prev
53
 
54
    COMPREPLY=()
55
    _get_comp_words_by_ref cur prev
56
 
57
    if [[ $1 == @(declare|typeset) ]]; then
58
        if [ "$prev" = -f ]; then
59
            COMPREPLY=( $( compgen -A function -- "$cur" ) )
60
        elif [[ "$cur" == -* ]]; then
61
            COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) )
62
        fi
63
    elif [ $COMP_CWORD -eq 1 ]; then
64
        COMPREPLY=( $( compgen -A function -- "$cur" ) )
65
    else
66
        COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
67
    fi
68
}
69
complete -F _function function declare typeset
70
 
71
# bash complete completion
72
#
73
_complete()
74
{
75
    local cur prev
76
 
77
    COMPREPLY=()
78
    _get_comp_words_by_ref cur prev
79
 
80
    case $prev in
81
        -o)
82
            COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames \
83
                nospace plusdirs' -- "$cur" ) )
84
            return 0
85
            ;;
86
 
87
        -A)
88
            COMPREPLY=( $( compgen -W 'alias arrayvar binding builtin command \
89
                directory disabled enabled export file function group \
90
                helptopic hostname job keyword running service setopt shopt \
91
                signal stopped user variable' -- "$cur" ) )
92
            return 0
93
            ;;
94
 
95
        -C)
96
            COMPREPLY=( $( compgen -A command -- "$cur" ) )
97
            return 0
98
            ;;
99
        -F)
100
            COMPREPLY=( $( compgen -A function -- "$cur" ) )
101
            return 0
102
            ;;
103
        -p|-r)
104
            COMPREPLY=( $( complete -p | sed -e 's|.* ||' ) )
105
            COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
106
            return 0
107
            ;;
108
 
109
    esac
110
 
111
    if [[ "$cur" == -* ]]; then
112
        # relevant options completion
113
        local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X"
114
        [[ $1 != compgen ]] && opts="$opts -F -C"
115
        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
116
    else
117
        COMPREPLY=( $( compgen -A command -- "$cur" ) )
118
    fi
119
}
120
complete -F _complete compgen complete
121
 
122
# Local variables:
123
# mode: shell-script
124
# sh-basic-offset: 4
125
# sh-indent-comment: t
126
# indent-tabs-mode: nil
127
# End:
128
# ex: ts=4 sw=4 et filetype=sh