bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Programmable completion and the @ symbol.


From: Ben Logan
Subject: Programmable completion and the @ symbol.
Date: Thu, 13 Jun 2002 19:16:54 -0400
User-agent: Mutt/1.2.5i

Hello, all.

I am trying to setup command line completion for the GRASS GIS (which
uses Bash as it's command shell), and have run into some trouble.
I'll use the GRASS command d.rast as an example.  Hopefully I can
describe the situation clearly enough for ya'll to be able to help me.

d.rast takes a map name as an argument.  A map name can either just be
a name like "elevation", or it can be a name+mapset_name like
"elevation@laurel_fork".  Mapsets are just a way to separate and
organize different maps, and you may have maps named the same thing in
different mapsets.

Here are a couple of sample commands:

d.rast elev
d.rast topo@laurel_fork

It is easy to get completion to work if I don't worry about mapsets,
because it is easy to generate a list of maps in the current or all
mapsets.  For example, I can type

d.rast el<Tab>

and get

d.rast elev

However, I wish that I could get it to work so that the completion
function presents a list of maps until an '@' is typed, and then
presents a list of mapsets.  To illustrate, let's assume that I have
the following maps:

In current mapset:
elevation1 elevation2

In mapset laurel_fork:
elevation1 topo

In mapset fancy_gap:
elevation1 topo topo2

I start typing...

d.rast <Tab><Tab>

and get a list like

elevation1 elevation2 topo topo2

Assuming I want topo2, I type

t<Tab>2

which results in

d.rast topo2

But topo2 is in mapset fancy_gap, so now I want to be able to type

@<Tab><Tab>   (So far I have 'd.rast topo2@')

and Bash present a list of mapsets:

laurel_fork fancy_gap

I feel like my explanation is about as clear as mud, but maybe you can
see what I'm after.  I can write shell functions to generate the lists
of maps and mapsets, I just can't get the completion to work.  I
think the problem is that the '@' symbol is a word delimiter, and is
screwing things up.  I also wish I could prevent Bash from printing
the space after it completes the first word, so that I don't have to
backspace once before typing the '@'. :)

Is all this even possible?  I suppose the completion routines (in the
C source) could be modified, but that's not really an option.  Not
only do I not have the know-how, but also want other GRASS users to
simply be able to source my Bash script to get completion to work.

I apologize for the length of this mail; thanks for your consideration.
Ben

-- 
Ben Logan: ben at wblogan dot net
OpenPGP Key KeyID: A1ADD1F0

Depend on the rabbit's foot if you will, but remember, it didn't help
the rabbit.
                -- R.E. Shay



reply via email to

[Prev in Thread] Current Thread [Next in Thread]