abra zsh config 2.0

This commit is contained in:
Andrey Anurin
2018-08-12 15:26:21 +03:00
parent 201abd09c4
commit 6b114440e2
1195 changed files with 68948 additions and 10539 deletions

View File

@@ -1,5 +1,30 @@
#compdef psql pg_dump pg_dumpall pg_restore createdb dropdb vacuumdb createuser dropuser initdb
# ------------------------------------------------------------------------------
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users, Dominic Mitchell, Johann 'Myrkraverk' Oskarsson, Daniel Serodio, J Smith
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
@@ -121,11 +146,21 @@ _pgsql_databases () {
local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
_pgsql_get_identity
local _pgsql_services _pgsql_service_files
_pgsql_service_files=(
~/.pg_service.conf
$(pg_config --sysconfdir)/pg_service.conf
)
_pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \
| sed -e 's/^\[/service=/' -e 's/\].*$//' )
local _pgsql_db_sql
_pgsql_db_sql="select d.datname from pg_catalog.pg_database d \
where d.datname <> 'template0'"
compadd "$@" - $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null )
compadd "$@" - \
${(f)_pgsql_services} \
$( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null )
}
_pgsql_encodings () {
@@ -154,8 +189,11 @@ _psql () {
{-A,--no-align}'[unaligned output mode]' \
{-c+,--command=}':execute SQL command:' \
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
{-b,--echo-errors}'[echo failed commands]' \
{-e,--echo-queries}'[display queries submitted]' \
{-E,--echo-hidden}'[display hidden queries]' \
{-L,--log-file=}'[send session log to file]' \
{-n,--no-readline}'[disable enhanced command line editing (readline)]' \
{-f+,--file=}':SQL file to read:_files' \
{-F+,--field-separator=}':field separator char:' \
{-H,--html}'[HTML output]' \
@@ -171,6 +209,8 @@ _psql () {
-u'[prompt for username/password]' \
{-v+,--set=,--variable=}':set SQL variable:' \
{-x,--expanded}'[one column per line]' \
{-z,--field-separator-zero}'[set field separator for unaligned output to zero byte]' \
{-0,--record-separator-zero}'[set record separator for unaligned output to zero byte]' \
{-X,--no-psqlrc}'[dont read ~/.psqlrc]' \
':PostgreSQL database:_pgsql_databases' \
':PostgreSQL user:_pgsql_users'
@@ -191,6 +231,7 @@ _pg_dump () {
{-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \
{-f+,--file=}':output file:_files' \
{-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
{-j,--jobs=}'[use this many parallel jobs to dump]' \
{-i,--ignore-version}'[ignore version mismatch]' \
{-n+,--schema=}':schema to dump:_pgsql_schemas' \
{-N+,--exclude-schema=}':schema to NOT dump:_pgsql_schemas' \
@@ -208,13 +249,23 @@ _pg_dump () {
{-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
':PostgreSQL database:_pgsql_databases' \
--section=':dump named section:_values "section" pre-data data post-data' \
--binary-upgrade'[for use by upgrade utilities only]' \
--column-inserts'[dump data as INSERT commands with column names]' \
--disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \
--disable-triggers'[disable triggers during data-only restore]' \
--enable-row-security'[enable row security (dump only content user has access to)]' \
--exclude-table-data='[do NOT dump data for the named table(s)]' \
--if-exists'[use IF EXISTS when dropping objects]' \
--inserts'[dump data as INSERT commands, rather than COPY]' \
--lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \
--no-security-labels'[do not dump security label assignments]' \
--no-synchronized-snapshots'[do not use synchronized snapshots in parallel jobs]' \
--no-tablespaces'[do not dump tablespace assignments]' \
--no-unlogged-table-data'[do not dump unlogged table data]' \
--quote-all-identifiers'[quote all identifiers, even if not key words]' \
--serializable-deferrable'[wait until the dump can run without anomalies]' \
--snapshot='[use given snapshot for the dump]' \
--strict-names'[require table and/or schema include patterns to match at least one entity each]' \
--use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]'
}
@@ -341,6 +392,7 @@ _createuser () {
{-d,--createdb}'[role can create new databases]' \
{-D,--no-createdb}'[role cannot create databases]' \
{-E,--encrypted}'[encrypt stored password]' \
{-g,--role=}'[new role will be a member of this role]' \
{-i,--inherit}'[role inherits privileges of roles it is a member of (default)]' \
{-I,--no-inherit}'[role does not inherit privileges]' \
{-l,--login}'[role can login (default)]' \
@@ -350,7 +402,10 @@ _createuser () {
{-r,--createrole}'[role can create new roles]' \
{-R,--no-createrole}'[role cannot create roles]' \
{-s,--superuser}'[role will be superuser]' \
{-S,--no-superuser}'[role will not be superuser]'
{-S,--no-superuser}'[role will not be superuser]' \
{--interactive}'[prompt for missing role name and attributes rather than using defaults]' \
{--replication}'[role can initiate replication]' \
{--no-replication}'[role cannot initiate replication]' \
}
_dropuser () {
@@ -361,7 +416,7 @@ _dropuser () {
"$_pgsql_common_opts[@]" \
{-e,--echo}'[display SQL queries]' \
{-q,--quiet}'[non verbose mode]' \
{-i,--interactive}'[confirm before drop]' \
{-i,--interactive}'[prompt before deleting anything, and prompt for role name if not specified]' \
':PostgreSQL user:_pgsql_users'
}
@@ -371,6 +426,8 @@ _initdb () {
_arguments -C -s \
{--auth=,-A+}':default authentication method for local connections:_values "auth methods" $_pgsql_auth_methods[@]' \
--auth-host=':default authentication method for local TCP/IP connections:_values "auth methods" $_pgsql_auth_methods[@]' \
--auth-local=':default authentication method for local-socket connections:_values "auth methods" $_pgsql_auth_methods[@]' \
{-D+,--pgdata=}':location for this database cluster:_files' \
{-E+,--encoding=}':set default encoding for new databases:' \
--locale=':set default locale for new databases:' \
@@ -388,8 +445,11 @@ _initdb () {
{-X+,--xlogdir=}':location for the transaction log directory:_files' \
{-d,--debug}'[generate lots of debugging output]' \
-L+':where to find the input files:_files' \
{-k,--data-checksums}':use data page checksums:' \
{-n,--noclean}'[do not clean up after errors]' \
{-N,--nosync}':do not wait for changes to be written safely to disk:' \
{-s,--show}'[show internal settings]' \
{-S,--sync-only}'[only sync data directory]' \
':location for this database cluster:_files'
}
@@ -402,6 +462,7 @@ _pgsql_utils () {
{-p+,--port=}':database port number:_pgsql_ports'
{-U+,--username=}':connect as user:_pgsql_users'
{-W,--password}'[prompt for password]'
--role='[do SET ROLE before restore]'
)
_pgsql_auth_methods=(