[GRASS-dev] Simple bash auto-completion for GRASS

Hi,

he is the simple incomplete version of auto-completion for GRASS bash
command line.

Implemented only of two commands -- d.rast and d.vect -- and works
only in the case with single parameter (d.vect mapname). It completes
the name of raster/vector map (for all mapsets as returned by
g.mlist).

How to test it: in the GRASS command line run "source
bash_completion.sh". Type "d.rast " and press TAB.

I don't know what should be auto-completed; how to deal with the
number of GRASS commands; if/how to handle parameters; what are
side-effects; how it works on various systems/shells; and how to
integrated into GRASS. The question which I tried to answer is: Is
that possible?

Vaclav

(attachments)

bash_completion.sh (800 Bytes)

Vaclav Petras wrote:

Hi,

he is the simple incomplete version of auto-completion for GRASS bash
command line.

Thanks for the attempt Vaclav. This would be a POWER-feature :slight_smile:

Implemented only of two commands -- d.rast and d.vect -- and works
only in the case with single parameter (d.vect mapname). It completes
the name of raster/vector map (for all mapsets as returned by
g.mlist).

How to test it: in the GRASS command line run "source
bash_completion.sh". Type "d.rast " and press TAB.

I don't know what should be auto-completed;

I think it would be a great time-saver if it would be possible to
auto-complete existing map (file)names for parameters like "input=",
"map=" and why not (sub-)group names (think of i.group group=...) and
color rules (think of r.colors map=... color=...).

how to deal with the number of GRASS commands; if/how to handle parameters;
what are side-effects; how it works on various systems/shells; and how to
integrated into GRASS. The question which I tried to answer is: Is
that possible?

Thank you, Nikos

On 05/02/13 12:02, Vaclav Petras wrote:

Hi,

he is the simple incomplete version of auto-completion for GRASS bash
command line.

Implemented only of two commands -- d.rast and d.vect -- and works
only in the case with single parameter (d.vect mapname). It completes
the name of raster/vector map (for all mapsets as returned by
g.mlist).

How to test it: in the GRASS command line run "source
bash_completion.sh". Type "d.rast " and press TAB.

I don't know what should be auto-completed; how to deal with the
number of GRASS commands; if/how to handle parameters; what are
side-effects; how it works on various systems/shells; and how to
integrated into GRASS. The question which I tried to answer is: Is
that possible?

You might want to look at this old implementation:

http://www.sorokine.info/grass-complete/

Moritz

Vaclav wrote:

he is the simple incomplete version of auto-completion
for GRASS bash command line.

Hi,

did you know about the previous work on this for grass 5?
It would need updating for sure, but maybe a lot of the work is
already done for you.

It is still online:
   http://www.sorokine.info/grass-complete/

Hamish

On 5 February 2013 12:42, Hamish <hamish_b@yahoo.com> wrote:

Vaclav wrote:

he is the simple incomplete version of auto-completion
for GRASS bash command line.

Hi,

did you know about the previous work on this for grass 5?
It would need updating for sure, but maybe a lot of the work is
already done for you.

It is still online:
   http://www.sorokine.info/grass-complete/

Hi, I didn't. So it was even working some day. It might be useful if
somebody (not sure if me) will actually write the general completion.
However, it is for g5, bash 2 (I have 4) and it is written in perl.
For g7 it should be probably in Python. While looking to the code, I'm
afraid of various shells differences. Finally, there is
--interface-description (with the parameter type) which would help to
build the completion files (not there is some parsing and guessing).
This part might be even easier than it was for 5.

Nevertheless, it seems that there was and is an interest in this.

Vaclav

Hamish