[GRASS-user] grass prompt when changing locations

Hi,

When I change locations within a grass session with g.mapset, the
prompt is not updated. If I start grass with:

grass -text ~/grassdata/dem/PERMANENT

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?

Thanks,

Tyler

Grass 6.4.1
Ubuntu Oneiric

Hi,

When I change locations within a grass session with g.mapset, the
prompt is not updated. If I start grass with:

grass -text ~/grassdata/dem/PERMANENT

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 > "

On Wed, Mar 14, 2012 at 10:33 AM, Micha Silver <micha@arava.co.il> wrote:

On 03/14/2012 03:55 PM, 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 > "

Thanks!

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?

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

Cheers,

Tyler

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@gclements.plus.com>

On Thu, Mar 15, 2012 at 10:40 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Tyler Smith wrote:

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).

Thanks for the explanation Glynn.

I'm running Grass from Emacs, and have written the rough framework of
a dedicated Grass mode. So instead of running g.mapset, I call M-x
grass-change-location, which prompts for location and mapset, then
calls g.mapset with that information. The final piece was getting the
same function to reset the prompt, and now it's relatively seamless.

Cheers,

Tyler

On Thu, 15 Mar 2012, Tyler Smith wrote:

I'm running Grass from Emacs, and have written the rough framework of a
dedicated Grass mode. So instead of running g.mapset, I call M-x
grass-change-location, which prompts for location and mapset, then calls
g.mapset with that information. The final piece was getting the same
function to reset the prompt, and now it's relatively seamless.

Tyler,

   Are you willing to share your .el with the rest of us who depend on emacs
for text editing? I use ESS (Emacs Speaks S) when I'm writing and running R
statistical models in emacs, and the modes for SQL, Python, and C. I can
appreciate the advantages of running grass within it.

Rich

On Thu, Mar 15, 2012 at 11:27 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Thu, 15 Mar 2012, Tyler Smith wrote:

I'm running Grass from Emacs, and have written the rough framework of a
dedicated Grass mode. So instead of running g.mapset, I call M-x
grass-change-location, which prompts for location and mapset, then calls
g.mapset with that information. The final piece was getting the same
function to reset the prompt, and now it's relatively seamless.

Tyler,

Are you willing to share your .el with the rest of us who depend on emacs
for text editing? I use ESS (Emacs Speaks S) when I'm writing and running R
statistical models in emacs, and the modes for SQL, Python, and C. I can
appreciate the advantages of running grass within it.

Absolutely, I'm planning to do that shortly (and will announce it on
this list). Probably this weekend - I just need to tidy it up a bit
and open the bitbucket repository.

Cheers,

Tyler

On Thu, 15 Mar 2012, Tyler Smith wrote:

Absolutely, I'm planning to do that shortly (and will announce it on this
list). Probably this weekend - I just need to tidy it up a bit and open
the bitbucket repository.

Tyler,

   Thanks.

Rich

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15/03/12 16:47, Tyler Smith wrote:

On Thu, Mar 15, 2012 at 11:27 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Thu, 15 Mar 2012, Tyler Smith wrote:

I'm running Grass from Emacs, and have written the rough framework of a dedicated Grass
mode. So instead of running g.mapset, I call M-x grass-change-location, which prompts for
location and mapset, then calls g.mapset with that information. The final piece was getting
the same function to reset the prompt, and now it's relatively seamless.

Tyler,

Are you willing to share your .el with the rest of us who depend on emacs for text editing? I
use ESS (Emacs Speaks S) when I'm writing and running R statistical models in emacs, and the
modes for SQL, Python, and C. I can appreciate the advantages of running grass within it.

Absolutely, I'm planning to do that shortly (and will announce it on this list). Probably this
weekend - I just need to tidy it up a bit and open the bitbucket repository.

Brilliant - I was looking for something like that for a long time.

The next step is then integration into org-mode. I am using org-mode with R, GRASS and shell to do
analysis - a GRASS mode would be brilliant!

Really looking forward to it,

Rainer

Cheers,

Tyler _______________________________________________ grass-user mailing list
grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.
(Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44

Fax (D): +49 - (0)3 21 21 25 22 44

email: Rainer@krugs.de

Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9i98kACgkQoYgNqgF2egrXAACgibN9jEJDfJfCkZ9eHzkc5fjl
8ZoAn2ajD+j3TYc+Z+JxS3lx5A2Vk8Eo
=TY6J
-----END PGP SIGNATURE-----