PageRenderTime 85ms CodeModel.GetById 82ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/bash_completion_lib/complete -o default/psql

http://github.com/brinkman83/bashrc
#! | 48 lines | 41 code | 7 blank | 0 comment | 0 complexity | 2ef38334ad67dc6a8efb6beb25453ecb MD5 | raw file
 1comp_include _filedir _get_cword _known_hosts _pg_databases _pg_users
 2
 3
 4_psql()
 5{
 6    local cur prev
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10    prev=${COMP_WORDS[COMP_CWORD-1]}
11
12    case "$prev" in
13    -h|--host) 
14        _known_hosts
15        return 0
16        ;;
17    -U|--username)
18        _pg_users
19        return 0
20        ;;
21    -d|--dbname)
22        _pg_databases
23        return 0
24        ;;
25    -@(o|f)|--output|--file)
26        _filedir
27        return 0
28        ;;
29    esac
30
31    if [[ "$cur" == -* ]]; then
32        # return list of available options
33        COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \
34            -c --command -d --dbname -e --echo-queries \
35            -E --echo-hidden -f --file -F --filed-separator \
36            -h --host -H --html -l --list -n -o --output \
37            -p --port -P --pset -q -R --record-separator \
38            -s --single-step -S --single-line -t --tuples-only \
39            -T --table-attr -U --username -v --variable \
40            -V --version -W --password -x --expanded -X --nopsqlrc \
41            -? --help ' -- $cur ) )
42    else
43        # return list of available databases
44        _pg_databases
45    fi
46} # _psql()
47
48