[GRASS-user] grass prompt default working directory

Hamish hamish_b at yahoo.com
Tue Feb 26 12:17:08 PST 2013


Hi,

a couple of points,


firstly, you can add this to ~/.grass.bashrc:

g.cd()
{
  MAPSET=`g.gisenv get=MAPSET`
  LOCATION_NAME=`g.gisenv get=LOCATION_NAME`
  GISDBASE=`g.gisenv get=GISDBASE`
  LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
  cd "$LOCATION"
}

(as I just did, nice idea, thanks!)


these used to be enviro vars in earlier versions of GRASS, but
were changed to g.gisenv enviro vars as changing context needs
to happen for the whole GIS. Once the GUI is launched, any changes
to enviro vars in either it or the command prompt only propogate
to children of each, not to siblings or past-spawned children
processes. So the command prompt and GUI would get out of sync
wrt which mapset or location you are in and it would be a big
mess.


Note that the mapset dir is (in a way) set to be the home dir
in a soft way, so that .bash_history for the grass command
session is written to the mapset dir, not real $HOME. Using
that, the above g.cd could be simplifiled to:

  alias g.home='cd `dirname "$HISTFILE"`'


Hamish


More information about the grass-user mailing list