Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / bash-completion / completions / | server ip : 172.67.156.115 your ip : 172.69.58.98 H O M E |
Filename | /usr/share/bash-completion/completions/dropdb |
Size | 3.33 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:54 |
Last modified | 07-Apr-2014 22:10 |
Last accessed | 05-Jul-2025 20:38 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
# bash completion for Postgresql -*- shell-script -*-
_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 -AtqwlF $'\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 -Atqwc 'select usename from pg_user' \
template1 2>/dev/null )" -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) )
}
# createdb(1) completion
#
_createdb()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username|-O|--owner)
_pg_users
return 0
;;
-p|--port|-D|--tablespace|-E|--encoding|-T|--template)
# argument required but no completions available
return 0
;;
--help|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_pg_databases
fi
} &&
complete -F _createdb -o default createdb
# dropdb(1) completion
#
_dropdb()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username)
_pg_users
return 0
;;
--help|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_pg_databases
fi
} &&
complete -F _dropdb -o default dropdb
# psql(1) completion
#
_psql()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username)
_pg_users
return 0
;;
-d|--dbname)
_pg_databases
return 0
;;
-o|--output|-f|--file|-L|--log-file)
_filedir
return 0
;;
-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 0
;;
-\?|--help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
# return list of available databases
_pg_databases
fi
} &&
complete -F _psql psql
# ex: ts=4 sw=4 et filetype=sh
_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 -AtqwlF $'\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 -Atqwc 'select usename from pg_user' \
template1 2>/dev/null )" -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) )
}
# createdb(1) completion
#
_createdb()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username|-O|--owner)
_pg_users
return 0
;;
-p|--port|-D|--tablespace|-E|--encoding|-T|--template)
# argument required but no completions available
return 0
;;
--help|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_pg_databases
fi
} &&
complete -F _createdb -o default createdb
# dropdb(1) completion
#
_dropdb()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username)
_pg_users
return 0
;;
--help|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_pg_databases
fi
} &&
complete -F _dropdb -o default dropdb
# psql(1) completion
#
_psql()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
return 0
;;
-U|--username)
_pg_users
return 0
;;
-d|--dbname)
_pg_databases
return 0
;;
-o|--output|-f|--file|-L|--log-file)
_filedir
return 0
;;
-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 0
;;
-\?|--help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
# return list of available databases
_pg_databases
fi
} &&
complete -F _psql psql
# ex: ts=4 sw=4 et filetype=sh