command prompter

Christopher Browne cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Fri Oct 2 20:35:37 UTC 2009


On Fri, Oct 2, 2009 at 1:41 PM, Chris F.A. Johnson <chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org> wrote:
> On Fri, 2 Oct 2009, Terrence Enger wrote:
>
>> Greetings,
>>
>> I am used, working on another platform, to having a tool which relieves
>> of the need to remember command line parameters ... sort of an entry
>> panel with brief prompts and hyperlinks to the applicable part of the
>> man page.
>>
>> Is there such a tool for GNU/Linux?  Nothing applicable jumped out at me
>> from the first hundred results of a google search for linux command
>> prompter.
>>
>> If this does not already exist, is there anybody else who thinks maybe
>> it should?  If anybody expresses an interest, I shall put together an
>> example of what it might do for you.
>
>    You could do it with bash's completion functions.

The "granddaddy" of this is the zsh completion functionality...

http://zsh.sourceforge.net/Doc/Release/zsh_19.html

A significant example that I use is the completion functions for PostgreSQL...

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

For instance, it encodes the arguments for the "psql" client thus:

_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'
}

As a result of the above, if you type...

psql -[tab]

it'll display (in a fairly attractive format) the list of possible
completions of the option.


-- 
http://linuxfinances.info/info/linuxdistributions.html
Ted Turner  - "Sports is like a war without the killing." -
http://www.brainyquote.com/quotes/authors/t/ted_turner.html
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list