[GRASS-user] grass prompt when changing locations

Glynn Clements glynn at gclements.plus.com
Thu Mar 15 10:40:34 EDT 2012


Tyler Smith wrote:

> > > my prompt looks like this:
> > >
> > > GRASS 6.4.1 (dem):~ >
> > >
> > > The reference to the location '(dem)' stays, even after changing to
> > > another location. How do I make Grass update this?
> >
> > The new environment variables are stored in the $LOCATION_NAME/$MAPSET/.bashrc file (if you're using bash). But this file is not 'source'ed when changing mapsets. So you need to do:
> > eval `g.gisenv`
> > source $GISDBASE/$LOCATION_NAME/$MAPSET/.bashrc
> >
> > or manually reset the prompt:
> > export PS1="GRASS-6.4.2 ($LOCATION_NAME) \w > "
> 
> There is no .bashrc file in the mapset directory, so I take it I would
> have to set that up for each mapset in each location?

It's created when you start a GRASS session. There's no point in
creating it manually, as it will never be read, and will be
overwritten the next time you start a GRASS session in that directory.

Creating the .bashrc file in the mapset directory is something of a
hack. The startup script sets HOME to the mapset directory so that the
.bash_history file will be created there (so each mapset gets its own
command history). That causes the .bashrc file file to be read from
the mapset directory; the .bashrc file then restores HOME.

> Manually resetting the prompt works fine, after eval 'g.gisenv`, so
> that is what I'm using now.

There isn't any simple way to fix this. A command such as g.mapset
cannot change the environment of another process (e.g. the shell from
which g.mapset was run).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list