[GRASSLIST:6016] MASK in the GRASS prompt - was: Re: Re: Problem using r.in.ascii
Markus Neteler
neteler at itc.it
Fri Apr 11 03:50:53 EDT 2003
On Thu, Apr 10, 2003 at 04:54:44PM +0100, Glynn Clements wrote:
> Markus Neteler wrote:
[...]
> > What if there were the work 'MASK' or just 'M' in the GRASS prompt?
> > I was fighing with the same problem recently ...
> >
> > Something like
> > GRASS:~ >
> > and
> > GRASS(M):~ >
> >
> > in case a MASK is present. Maybe there is a possibility to
> > add a file check to
> > PS1='GRASS:\w > '
> > ?
>
> With bash, the variable PROMPT_COMMAND can be used to specify a
> command which is run before printing the prompt. E.g.
>
> PROMPT_COMMAND='if r.info MASK &> /dev/null ; then echo -n "GRASS(M):" ; else echo -n "GRASS:" ; fi'
> PS1='\w '
>
> Except that the above will repeatedly send you email with the error
> message from r.info when MASK doesn't exist. Ideally, you want a
> dedicated utility which tests for the existence of a mask.
Thanks for the idea!
An alternate hack solving the mail problem is:
PROMPT_COMMAND='if test -f `g.gisenv GISDBASE`/`g.gisenv LOCATION_NAME`/`g.gisenv MAPSET`/cell/MASK ; then echo -n "GRASS(M):" ; else echo -n "GRASS:" ; fi'
PS1='\w >'
Works without sending mails.
Markus
More information about the grass-user
mailing list