zsh-users
 help / color / mirror / code / Atom feed
* PostgreSQL completion
@ 2004-09-15  6:40 Dominic Mitchell
  2004-09-15  9:28 ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Dominic Mitchell @ 2004-09-15  6:40 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

I've got some way through a (hopefully) useful completion for
PostgreSQL.  It's useful as it stands, but I have a few questions about
some bits of it.

1.  I use psql to get information from the database.  But what happens
if psql spits out an error?  At the moment, it just messes up the
display...

2.  How do you complete either a hostname or a path at the same point?
PostgreSQL accepts either a hostname or a directory containing a socket
after -h.

Anyway, I hope this is useful to somebody.

-Dom

[-- Attachment #2: Zsh completion for PostgreSQL --]
[-- Type: text/plain, Size: 7076 bytes --]

#compdef psql pg_dump createdb dropdb

#
# zsh completion functions for PostgreSQL client programs.  Based on
# _mysql_utils.
#
# Dominic Mitchell <dom+zsh@happygiraffe.net>
#

_pgsql_get_identity () {
    _pgsql_user=${(v)opt_args[(i)-U|--username]}
    _pgsql_port=${(v)opt_args[(i)-p|--port]}
    _pgsql_host=${(v)opt_args[(i)-h|--host]}

    _pgsql_params=(
        ${_pgsql_user:+"--username=$_pgsql_user"}
        ${_pgsql_port:+"--port=$_pgsql_port"}
        ${_pgsql_host:+"--host=$_pgsql_host"}
    )
}

_pgsql_users () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # We use _pgsql_port and _pgsql_host directly here instead of
    # _pgsql_params so as to not pick up a partially completed
    # username.
    _pgsql_params=(
        ${_pgsql_port:+"--port=$_pgsql_port"}
        ${_pgsql_host:+"--host=$_pgsql_host"}
    )

    compadd "$@" - ${${(f)~~"$( psql $_pgsql_params[@] -At -c '\du' template1 )"}[@]%%|*}
}

_pgsql_tables () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # Need to pull out the database name from the existing arguments.
    # This is going to vary between commands.  Thankfully, it's only
    # used by pg_dump, which always has the dbname in arg1.  If it's
    # not present it defaults to ${PGDATABASE:-$LOGNAME}, which
    # matches (I think) the PostgreSQL behaviour.

    local db
    db=${line[1]:-${PGDATABASE:-$LOGNAME}}

    # XXX In postgres 7.3 and above, the schema name is in the first
    # column.  I'm not sure how best to work around that...  It really
    # needs to be prepended with a "." to the table name.

    # Many thanks to Oliver Kiddle for pointing out how to get the 2nd
    # column out of this...
    compadd "$@" - \
        ${${${(f)~~"$( psql $_pgsql_params[@] -At -c '\dt' $db )"}#*|}%%|*}
}

_pgsql_databases () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # Should I grep out template0?
    compadd "$@" - ${${(f)~~"$( psql $_pgsql_params[@] -At -l)"}[@]%%|*} 
}


##
## The actual completion code for the commands
##

_psql () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-V,--version}'[display client version]' \
        {-a,--echo-all}'[print commands read]' \
        {-A,--no-align}'[unaligned output mode]' \
        {-c+,--command=}':execute SQL command:' \
        {-d+,--dbname=}':database to connect to:_pgsql_databases' \
        {-e,--echo-queries}'[display queries submitted]' \
        {-E,--echo-hidden}'[display hidden queries]' \
        {-f+,--file=}':SQL file to read:_files' \
        {-F+,--field-separator=}':field separator char:' \
        {-H,--html}'[HTML output]' \
        {-l,--list}'[list databases]' \
        {-o+,--output=}':query output:_files' \
        {-P+,--pset=}':set psql variable:' \
        {-q,--quiet}'[non verbose mode]' \
        {-R+,--record-separator=}':record separator char:' \
        {-s,--single-step}'[prompt before each query]' \
        {-S,--single-line}'[newline sends query]' \
        {-t,--tuples-only}'[dont display header/footer]' \
        {-T+,--table-attr=}':HTML table options:' \
        -u'[prompt for username/password]' \
        {-v+,--set=,--variable=}':set SQL variable:' \
        {-x,--expanded}'[one column per line]' \
        {-X,--no-psqlrc}'[dont read ~/.psqlrc]' \
        ':PostgreSQL database:_pgsql_databases' \
        ':PostgreSQL user:_pgsql_users'
}

_pg_dump () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-a,--data-only}'[dump only data]' \
        {-b,--blobs}'[dump blobs as well]' \
        {-c,--clean}'[include clean cmds in dump]' \
        {-C,--create}'[include createdb cmds in dump]' \
        {-d,--inserts}'[use INSERT not COPY]' \
        {-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]"' \
        {-i,--ignore-version}'[ignore version mismatch]' \
        {-n+,--schema=}':schema to dump:' \
        {-o,--oids}'[dump objects identifiers for every table]' \
        {-O,--no-owner}'[dont recreate as same owner]' \
        {-R,--no-reconnect}'[dont output connect]' \
        {-s,--schema-only}'[no data, only schema]' \
        {-S+,--superuser=}':superuser name:_pgsql_users' \
        {-t+,--table=}':table to dump:_pgsql_tables' \
        {-v,--verbose}'[verbose mode]' \
        {-V,--version}'[display client version]' \
        {-x,--no-{acl,privileges}}'[dont dump ACLs]' \
        -X+':option:_values "option" use-set-session-authorization disable-triggers' \
        {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
        ':PostgreSQL database:_pgsql_databases'
}

_createdb () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-e,--echo}'[display SQL queries]' \
        {-q,--quiet}'[non verbose mode]' \
        {-D+,--location=}':database location:_directories' \
        {-T+,--template=}':database template:_pgsql_databases' \
        {-E+,--encoding=}':database encoding:_values "encoding" $_pgsql_encodings[@]' \
        ':PostgreSQL database:' \
        ':comment:'
}

_dropdb () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-e,--echo}'[display SQL queries]' \
        {-q,--quiet}'[non verbose mode]' \
        {-i,--interactive}'[confirm before drop]' \
        ':PostgreSQL database:_pgsql_databases'
}

_pgsql_utils () {
    local _pgsql_common_opts _pgsql_encodings

    _pgsql_common_opts=(
        {-\?,--help}'[display help]'
        # XXX This can also complete the path to a directory which
        # contains the postgresql socket (eg: /tmp).  I'm not sure how
        # to say that though.
        {-h+,--host=}':database host:_hosts'
        # Postgres doesn't like service names here, which is why we
        # don't use _ports.
        {-p+,--port=}':database port number:'
        {-U+,--username=}':connect as user:_pgsql_users'
        {-W,--password}'[prompt for password]'
    )

    # Taken from
    # <http://www.postgresql.org/docs/7.4/static/multibyte.html#CHARSET-TABLE>.
    # It'd be real nice if postgres could tell us these...
    _pgsql_encodings=(
        SQL_ASCII
        EUC_{JP,CN,KR,TW}
        JOHAB
        UNICODE
        MULE_INTERNAL
        LATIN{1,2,3,4,5,6,7,8,9,10}
        ISO_8859_{5,6,7,8}
        KOI8
        WIN
        ALT
        WIN1256
        TCVN
        WIN874
    )

    case "$service" in
        psql)     _psql "$@"     ;;
        pg_dump)  _pg_dump "$@"  ;;
        createdb) _createdb "$@" ;;
        dropdb)   _dropdb "$@"   ;;
    esac
}

_pgsql_utils "$@"

# vim: set ai et sw=4 syntax=zsh :

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2004-09-15  6:40 PostgreSQL completion Dominic Mitchell
@ 2004-09-15  9:28 ` Peter Stephenson
  2004-09-15  9:57   ` Dominic Mitchell
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2004-09-15  9:28 UTC (permalink / raw)
  To: zsh-users

Dominic Mitchell wrote:
> 1.  I use psql to get information from the database.  But what happens
> if psql spits out an error?  At the moment, it just messes up the
> display...

The usual method is simply to add 2>/dev/null to the command.  If you
want to be smarter about errors you need to work harder.

> 2.  How do you complete either a hostname or a path at the same point?
> PostgreSQL accepts either a hostname or a directory containing a socket
> after -h.

The easy way is _alternative, assuming you have functions for both
cases.  _ssh does (after a bit of editing):

  _alternative \
    'hosts:remote host name:_ssh_hosts' \
    'users:login name:_ssh_users -qS@'

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2004-09-15  9:28 ` Peter Stephenson
@ 2004-09-15  9:57   ` Dominic Mitchell
  2004-09-15 10:25     ` Dominic Mitchell
  0 siblings, 1 reply; 16+ messages in thread
From: Dominic Mitchell @ 2004-09-15  9:57 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Wed, Sep 15, 2004 at 10:28:03AM +0100, Peter Stephenson wrote:
> Dominic Mitchell wrote:
> > 1.  I use psql to get information from the database.  But what happens
> > if psql spits out an error?  At the moment, it just messes up the
> > display...
> 
> The usual method is simply to add 2>/dev/null to the command.  If you
> want to be smarter about errors you need to work harder.

Aha, good point.  I'll do that.  No need to be too clever, the same
error will be displayed at some point anyway.

> > 2.  How do you complete either a hostname or a path at the same point?
> > PostgreSQL accepts either a hostname or a directory containing a socket
> > after -h.
> 
> The easy way is _alternative, assuming you have functions for both
> cases.  _ssh does (after a bit of editing):
> 
>   _alternative \
>     'hosts:remote host name:_ssh_hosts' \
>     'users:login name:_ssh_users -qS@'

Excellent, I shall do that.  I tried looking for an example, I'll have
to try harder next time.  :-)

-Dom


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2004-09-15  9:57   ` Dominic Mitchell
@ 2004-09-15 10:25     ` Dominic Mitchell
  0 siblings, 0 replies; 16+ messages in thread
From: Dominic Mitchell @ 2004-09-15 10:25 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]

On Wed, Sep 15, 2004 at 10:57:50AM +0100, Dominic Mitchell wrote:
> On Wed, Sep 15, 2004 at 10:28:03AM +0100, Peter Stephenson wrote:
> > Dominic Mitchell wrote:
> > > 1.  I use psql to get information from the database.  But what happens
> > > if psql spits out an error?  At the moment, it just messes up the
> > > display...
> > 
> > The usual method is simply to add 2>/dev/null to the command.  If you
> > want to be smarter about errors you need to work harder.
> 
> Aha, good point.  I'll do that.  No need to be too clever, the same
> error will be displayed at some point anyway.
> 
> > > 2.  How do you complete either a hostname or a path at the same point?
> > > PostgreSQL accepts either a hostname or a directory containing a socket
> > > after -h.
> > 
> > The easy way is _alternative, assuming you have functions for both
> > cases.  _ssh does (after a bit of editing):
> > 
> >   _alternative \
> >     'hosts:remote host name:_ssh_hosts' \
> >     'users:login name:_ssh_users -qS@'
> 
> Excellent, I shall do that.  I tried looking for an example, I'll have
> to try harder next time.  :-)

Ok, here's the latest one.  I'll find a web page to put this up on at
some point...

-Dom

[-- Attachment #2: _pgsql_utils --]
[-- Type: text/plain, Size: 7179 bytes --]

#compdef psql pg_dump createdb dropdb

#
# zsh completion functions for PostgreSQL client programs.  Based on
# _mysql_utils.
#
# Dominic Mitchell <dom+zsh@happygiraffe.net>
#

_pgsql_get_identity () {
    _pgsql_user=${(v)opt_args[(i)-U|--username]}
    _pgsql_port=${(v)opt_args[(i)-p|--port]}
    _pgsql_host=${(v)opt_args[(i)-h|--host]}

    _pgsql_params=(
        ${_pgsql_user:+"--username=$_pgsql_user"}
        ${_pgsql_port:+"--port=$_pgsql_port"}
        ${_pgsql_host:+"--host=$_pgsql_host"}
    )
}

# Postgres Allows specifying the path to the directory containing the
# socket as well as a hostname.
_pgsql_host_or_dir() {
    _alternative \
        'hosts:host:_hosts' \
        'directories:directory:_directories'
}

_pgsql_users () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # We use _pgsql_port and _pgsql_host directly here instead of
    # _pgsql_params so as to not pick up a partially completed
    # username.
    _pgsql_params=(
        ${_pgsql_port:+"--port=$_pgsql_port"}
        ${_pgsql_host:+"--host=$_pgsql_host"}
    )

    compadd "$@" - ${${(f)~~"$( psql $_pgsql_params[@] -At -c '\du' template1 2>/dev/null )"}[@]%%|*}
}

_pgsql_tables () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # Need to pull out the database name from the existing arguments.
    # This is going to vary between commands.  Thankfully, it's only
    # used by pg_dump, which always has the dbname in arg1.  If it's
    # not present it defaults to ${PGDATABASE:-$LOGNAME}, which
    # matches (I think) the PostgreSQL behaviour.

    local db
    db=${line[1]:-${PGDATABASE:-$LOGNAME}}

    # XXX In postgres 7.3 and above, the schema name is in the first
    # column.  I'm not sure how best to work around that...  It really
    # needs to be prepended with a "." to the table name.

    # Many thanks to Oliver Kiddle for pointing out how to get the 2nd
    # column out of this...
    compadd "$@" - \
        ${${${(f)~~"$( psql $_pgsql_params[@] -At -c '\dt' $db 2>/dev/null )"}#*|}%%|*}
}

_pgsql_databases () {
    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
    _pgsql_get_identity

    # Should I grep out template0?
    compadd "$@" - ${${(f)~~"$( psql $_pgsql_params[@] -At -l 2>/dev/null )"}[@]%%|*} 
}


##
## The actual completion code for the commands
##

_psql () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-V,--version}'[display client version]' \
        {-a,--echo-all}'[print commands read]' \
        {-A,--no-align}'[unaligned output mode]' \
        {-c+,--command=}':execute SQL command:' \
        {-d+,--dbname=}':database to connect to:_pgsql_databases' \
        {-e,--echo-queries}'[display queries submitted]' \
        {-E,--echo-hidden}'[display hidden queries]' \
        {-f+,--file=}':SQL file to read:_files' \
        {-F+,--field-separator=}':field separator char:' \
        {-H,--html}'[HTML output]' \
        {-l,--list}'[list databases]' \
        {-o+,--output=}':query output:_files' \
        {-P+,--pset=}':set psql variable:' \
        {-q,--quiet}'[non verbose mode]' \
        {-R+,--record-separator=}':record separator char:' \
        {-s,--single-step}'[prompt before each query]' \
        {-S,--single-line}'[newline sends query]' \
        {-t,--tuples-only}'[dont display header/footer]' \
        {-T+,--table-attr=}':HTML table options:' \
        -u'[prompt for username/password]' \
        {-v+,--set=,--variable=}':set SQL variable:' \
        {-x,--expanded}'[one column per line]' \
        {-X,--no-psqlrc}'[dont read ~/.psqlrc]' \
        ':PostgreSQL database:_pgsql_databases' \
        ':PostgreSQL user:_pgsql_users'
}

_pg_dump () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-a,--data-only}'[dump only data]' \
        {-b,--blobs}'[dump blobs as well]' \
        {-c,--clean}'[include clean cmds in dump]' \
        {-C,--create}'[include createdb cmds in dump]' \
        {-d,--inserts}'[use INSERT not COPY]' \
        {-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]"' \
        {-i,--ignore-version}'[ignore version mismatch]' \
        {-n+,--schema=}':schema to dump:' \
        {-o,--oids}'[dump objects identifiers for every table]' \
        {-O,--no-owner}'[dont recreate as same owner]' \
        {-R,--no-reconnect}'[dont output connect]' \
        {-s,--schema-only}'[no data, only schema]' \
        {-S+,--superuser=}':superuser name:_pgsql_users' \
        {-t+,--table=}':table to dump:_pgsql_tables' \
        {-v,--verbose}'[verbose mode]' \
        {-V,--version}'[display client version]' \
        {-x,--no-{acl,privileges}}'[dont dump ACLs]' \
        -X+':option:_values "option" use-set-session-authorization disable-triggers' \
        {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
        ':PostgreSQL database:_pgsql_databases'
}

_createdb () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-e,--echo}'[display SQL queries]' \
        {-q,--quiet}'[non verbose mode]' \
        {-D+,--location=}':database location:_directories' \
        {-T+,--template=}':database template:_pgsql_databases' \
        {-E+,--encoding=}':database encoding:_values "encoding" $_pgsql_encodings[@]' \
        ':PostgreSQL database:' \
        ':comment:'
}

_dropdb () {
    local curcontext="$curcontext" state line expl
    typeset -A opt_args

    _arguments -C -s \
        "$_pgsql_common_opts[@]" \
        {-e,--echo}'[display SQL queries]' \
        {-q,--quiet}'[non verbose mode]' \
        {-i,--interactive}'[confirm before drop]' \
        ':PostgreSQL database:_pgsql_databases'
}

_pgsql_utils () {
    local _pgsql_common_opts _pgsql_encodings

    _pgsql_common_opts=(
        {-\?,--help}'[display help]'
        {-h+,--host=}':database host:_pgsql_host_or_dir'
        # Postgres doesn't like service names here, which is why we
        # don't use _ports.
        {-p+,--port=}':database port number:'
        {-U+,--username=}':connect as user:_pgsql_users'
        {-W,--password}'[prompt for password]'
    )

    # Taken from
    # <http://www.postgresql.org/docs/7.4/static/multibyte.html#CHARSET-TABLE>.
    # It'd be real nice if postgres could tell us these...
    _pgsql_encodings=(
        SQL_ASCII
        EUC_{JP,CN,KR,TW}
        JOHAB
        UNICODE
        MULE_INTERNAL
        LATIN{1,2,3,4,5,6,7,8,9,10}
        ISO_8859_{5,6,7,8}
        KOI8
        WIN
        ALT
        WIN1256
        TCVN
        WIN874
    )

    case "$service" in
        psql)     _psql "$@"     ;;
        pg_dump)  _pg_dump "$@"  ;;
        createdb) _createdb "$@" ;;
        dropdb)   _dropdb "$@"   ;;
    esac
}

_pgsql_utils "$@"

# vim: set ai et sw=4 syntax=zsh :

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-07 14:58       ` Richard Hartmann
@ 2008-03-07 15:28         ` Peter Stephenson
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 2008-03-07 15:28 UTC (permalink / raw)
  To: zsh-users

"Richard Hartmann" wrote:
> On Fri, Mar 7, 2008 at 11:40 AM, Peter Stephenson <pws@csr.com> wrote:
> 
> >  We're always willing to add new completions for anything of wide interest.
>...
> Or just 'should not be some obscure tool no one ever even heard of'?

That's about the closest definition I've seen.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-07 10:40     ` Peter Stephenson
@ 2008-03-07 14:58       ` Richard Hartmann
  2008-03-07 15:28         ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Hartmann @ 2008-03-07 14:58 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Fri, Mar 7, 2008 at 11:40 AM, Peter Stephenson <pws@csr.com> wrote:

>  We're always willing to add new completions for anything of wide interest.

How would you define wide interest? Packaged by major distributions?
User base of at least X people? Has been around for y years?

Or just 'should not be some obscure tool no one ever even heard of'?


Richard


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:10   ` Richard Hartmann
@ 2008-03-07 10:40     ` Peter Stephenson
  2008-03-07 14:58       ` Richard Hartmann
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2008-03-07 10:40 UTC (permalink / raw)
  To: zsh-users

On Thu, 6 Mar 2008 19:10:17 +0100
"Richard Hartmann" <richih.mailinglist@gmail.com> wrote:
> >  Somewhat related: I have noticed quite
> 
> a few programs I use do not have completions. Is there any
> interest in /me trying to come up with a few new definitions?

We're always willing to add new completions for anything of wide interest.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-07  3:35       ` Bart Schaefer
@ 2008-03-07  9:07         ` Richard Hartmann
  0 siblings, 0 replies; 16+ messages in thread
From: Richard Hartmann @ 2008-03-07  9:07 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On Fri, Mar 7, 2008 at 4:35 AM, Bart Schaefer <schaefer@brasslantern.com> wrote:

>  Which is why the zsh installer creates /usr/share/zsh/site-functions
>  as an empty directory, and includes it in $fpath ...

Seems Debian already does the right thing and moves that to

  /usr/local/share/zsh/site-functions

'Surprises' like these are why I like zsh as much as I do :)


Richard


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-07  1:52     ` Richard Hartmann
@ 2008-03-07  3:35       ` Bart Schaefer
  2008-03-07  9:07         ` Richard Hartmann
  0 siblings, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2008-03-07  3:35 UTC (permalink / raw)
  To: zsh-users

On Mar 7,  2:52am, Richard Hartmann wrote:
} Subject: Re: PostgreSQL completion
}
} On Thu, Mar 6, 2008 at 7:24 PM, Chris Ross <cross+zsh@distal.com> wrote:
} 
} >   I'm not completely opposed to installing it in the system, but
} >  generally if I get a distribution of software that doesn't include
} >  something, I try not to confuse things by modifying the installation.
} 
} I know what you mean and normally, I agree. In some circumstances,
} it can be better to make stuff available to everyone using a system and
} keeping track of all changes in a central places.

Which is why the zsh installer creates /usr/share/zsh/site-functions
as an empty directory, and includes it in $fpath ...


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:24   ` Chris Ross
  2008-03-06 18:35     ` Frank Terbeck
  2008-03-06 18:44     ` Tomasz Pala
@ 2008-03-07  1:52     ` Richard Hartmann
  2008-03-07  3:35       ` Bart Schaefer
  2 siblings, 1 reply; 16+ messages in thread
From: Richard Hartmann @ 2008-03-07  1:52 UTC (permalink / raw)
  To: Chris Ross; +Cc: zsh-users

On Thu, Mar 6, 2008 at 7:24 PM, Chris Ross <cross+zsh@distal.com> wrote:

>   I'm not completely opposed to installing it in the system, but
>  generally if I get a distribution of software that doesn't include
>  something, I try not to confuse things by modifying the installation.

I know what you mean and normally, I agree. In some circumstances,
it can be better to make stuff available to everyone using a system and
keeping track of all changes in a central places.

Though you could put it into /usr/local and edit /etc/zshrc accordingly,
come to think of it :p


Richard


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:24   ` Chris Ross
  2008-03-06 18:35     ` Frank Terbeck
@ 2008-03-06 18:44     ` Tomasz Pala
  2008-03-07  1:52     ` Richard Hartmann
  2 siblings, 0 replies; 16+ messages in thread
From: Tomasz Pala @ 2008-03-06 18:44 UTC (permalink / raw)
  To: zsh-users

On Thu, Mar 06, 2008 at 13:24:12 -0500, Chris Ross wrote:

>   Is there a way to install the aforementioned file in my home, in some
> way, so it gets used?

fpath=(~/etc/zfunc $fpath)

-- 
Tomasz Pala <gotar@pld-linux.org>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:24   ` Chris Ross
@ 2008-03-06 18:35     ` Frank Terbeck
  2008-03-06 18:44     ` Tomasz Pala
  2008-03-07  1:52     ` Richard Hartmann
  2 siblings, 0 replies; 16+ messages in thread
From: Frank Terbeck @ 2008-03-06 18:35 UTC (permalink / raw)
  To: zsh-users

Chris Ross <cross+zsh@distal.com>:
> On Thu, 2008-03-06 at 19:08 +0100, Richard Hartmann wrote:
> > Try saving that file into
> > 
> >  /usr/share/zsh/4.?.?/functions/Completion/Unix/_psql
> > 
> > and rehashing (no idea if you need to do more, sorry).
> 
>   I'm not completely opposed to installing it in the system, but
> generally if I get a distribution of software that doesn't include
> something, I try not to confuse things by modifying the installation.
> 
>   Is there a way to install the aforementioned file in my home, in some
> way, so it gets used?

Yes, putting it somewhere in your $fpath will do the job.
And if you add a directory in your $HOME to it, it will do that as
well.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:08 ` Richard Hartmann
  2008-03-06 18:10   ` Richard Hartmann
@ 2008-03-06 18:24   ` Chris Ross
  2008-03-06 18:35     ` Frank Terbeck
                       ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Chris Ross @ 2008-03-06 18:24 UTC (permalink / raw)
  To: Richard Hartmann; +Cc: zsh-users


On Thu, 2008-03-06 at 19:08 +0100, Richard Hartmann wrote:
> Try saving that file into
> 
>  /usr/share/zsh/4.?.?/functions/Completion/Unix/_psql
> 
> and rehashing (no idea if you need to do more, sorry).

  I'm not completely opposed to installing it in the system, but
generally if I get a distribution of software that doesn't include
something, I try not to confuse things by modifying the installation.

  Is there a way to install the aforementioned file in my home, in some
way, so it gets used?

  Thanks...

                        - Chris



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06 18:08 ` Richard Hartmann
@ 2008-03-06 18:10   ` Richard Hartmann
  2008-03-07 10:40     ` Peter Stephenson
  2008-03-06 18:24   ` Chris Ross
  1 sibling, 1 reply; 16+ messages in thread
From: Richard Hartmann @ 2008-03-06 18:10 UTC (permalink / raw)
  To: Chris Ross; +Cc: zsh-users

Grr, tab-space is not a good idea in GMail..

On Thu, Mar 6, 2008 at 7:08 PM, Richard Hartmann
<richih.mailinglist@gmail.com> wrote:


>  Somewhat related: I have noticed quite

a few programs I use do not have completions. Is there any
interest in /me trying to come up with a few new definitions?


Richard


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PostgreSQL completion
  2008-03-06  3:21 Chris Ross
@ 2008-03-06 18:08 ` Richard Hartmann
  2008-03-06 18:10   ` Richard Hartmann
  2008-03-06 18:24   ` Chris Ross
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Hartmann @ 2008-03-06 18:08 UTC (permalink / raw)
  To: Chris Ross; +Cc: zsh-users

On Thu, Mar 6, 2008 at 4:21 AM, Chris Ross <cross+zsh@distal.com> wrote:


>    And, it has lots of cool stuff in it.  Sadly, I appear to have
>  forgotten enough about how to engineer the completion goo in zsh that
>  I don't know how to *use* it.  I'm running zsh 4.2, or 4.3 (different
>  on different machines), and postgres 8.2.

Try saving that file into

 /usr/share/zsh/4.?.?/functions/Completion/Unix/_psql

and rehashing (no idea if you need to do more, sorry).

As the completion is not in my Debian install, perhaps it would make
sense to add it?


Somewhat related: I have noticed quite
>
>    Is there either a more up-to-date completion set for postgres
>  command-line tools, and/or could someone give me a hand getting the
>  content in that post to work for me?
>
>    Thanks.
>
>                  - Chris
>
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* PostgreSQL completion
@ 2008-03-06  3:21 Chris Ross
  2008-03-06 18:08 ` Richard Hartmann
  0 siblings, 1 reply; 16+ messages in thread
From: Chris Ross @ 2008-03-06  3:21 UTC (permalink / raw)
  To: zsh-users


   Greetings.  In searching the world for information about zsh  
completions for the PostgreSQL command line tools, I found a post from  
Dom in 2004:

http://www.zsh.org/mla/users/2004/msg01006.html

   And, it has lots of cool stuff in it.  Sadly, I appear to have  
forgotten enough about how to engineer the completion goo in zsh that  
I don't know how to *use* it.  I'm running zsh 4.2, or 4.3 (different  
on different machines), and postgres 8.2.

   Is there either a more up-to-date completion set for postgres  
command-line tools, and/or could someone give me a hand getting the  
content in that post to work for me?

   Thanks.

                 - Chris


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-03-07 15:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-15  6:40 PostgreSQL completion Dominic Mitchell
2004-09-15  9:28 ` Peter Stephenson
2004-09-15  9:57   ` Dominic Mitchell
2004-09-15 10:25     ` Dominic Mitchell
2008-03-06  3:21 Chris Ross
2008-03-06 18:08 ` Richard Hartmann
2008-03-06 18:10   ` Richard Hartmann
2008-03-07 10:40     ` Peter Stephenson
2008-03-07 14:58       ` Richard Hartmann
2008-03-07 15:28         ` Peter Stephenson
2008-03-06 18:24   ` Chris Ross
2008-03-06 18:35     ` Frank Terbeck
2008-03-06 18:44     ` Tomasz Pala
2008-03-07  1:52     ` Richard Hartmann
2008-03-07  3:35       ` Bart Schaefer
2008-03-07  9:07         ` Richard Hartmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).