diff options
Diffstat (limited to 'completions/psql')
-rw-r--r-- | completions/psql | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/completions/psql b/completions/psql index 86a66030..ceedf07e 100644 --- a/completions/psql +++ b/completions/psql @@ -4,16 +4,16 @@ _pg_databases() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 # "Access privileges" in output may contain linefeeds, hence the NF > 1 - COMPREPLY=( $( compgen -W "$( psql -XAtqwlF $'\t' 2>/dev/null | \ - awk 'NF > 1 { print $1 }' )" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null | \ + awk 'NF > 1 { print $1 }')" -- "$cur") ) } _pg_users() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 - COMPREPLY=( $( compgen -W "$( psql -XAtqwc 'select usename from pg_user' \ - template1 2>/dev/null )" -- "$cur" ) ) - [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) ) + COMPREPLY=( $(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \ + template1 2>/dev/null)" -- "$cur") ) + [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $(compgen -u -- "$cur") ) } # createdb(1) completion @@ -24,20 +24,15 @@ _createdb() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username|-O|--owner) + --username|--owner|-!(-*)[UO]) _pg_users return ;; - -p|--port|-D|--tablespace|-E|--encoding|-T|--template) - # argument required but no completions available - return - ;; - --help|--version) - # all other arguments are noop with these + --help|--version|--port|--tablespace|--encoding|--template|-!(-*)[pDET]) return ;; esac @@ -45,7 +40,7 @@ _createdb() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_databases @@ -61,14 +56,14 @@ _createuser() _init_completion -s || return case $prev in - --help|--version|-p|--port|-c|--connection-limit) + --help|--version|--port|--connection-limit|-!(-*)[pc]) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; @@ -77,7 +72,7 @@ _createuser() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && @@ -91,16 +86,15 @@ _dropdb() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; --help|--version) - # all other arguments are noop with these return ;; esac @@ -108,7 +102,7 @@ _dropdb() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_databases @@ -124,14 +118,14 @@ _dropuser() _init_completion -s || return case $prev in - --help|--version|-p|--port) + --help|--version|--port|-!(-*)p) return ;; - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; @@ -140,7 +134,7 @@ _dropuser() $split && return if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else _pg_users @@ -156,29 +150,24 @@ _psql() _init_completion -s || return case $prev in - -h|--host) + --host|-!(-*)h) _known_hosts_real -- "$cur" return ;; - -U|--username) + --username|-!(-*)U) _pg_users return ;; - -d|--dbname) + --dbname|-!(-*)d) _pg_databases return ;; - -o|--output|-f|--file|-L|--log-file) + --output|--file|--log-file|-!(-*)[ofL]) _filedir return ;; - -c|--command|-F|--field-separator|-p|--port|-P|--pset|\ - -R|--record-separator|-T|--table-attr|-v|--set|--variable) - # argument required but no completions available - return - ;; - -\?|--help|-V|--version) - # all other arguments are noop with these + --help|--version|--command|--field-separator|--port|--pset|\ + --record-separator|--table-attr|--set|--variable|-!(-*)[?VcFpPRTv]) return ;; esac @@ -187,7 +176,7 @@ _psql() if [[ "$cur" == -* ]]; then # return list of available options - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) [[ $COMPREPLY == *= ]] && compopt -o nospace else # return list of available databases |