[GRASS-dev] Bash aliases in GRASS

Hi,

what is the reason for not-loading bash aliases and the user bashrc
file when starting new bash? It is meant to prevent conflicts?

Vaclav

Vaclav Petras wrote:

what is the reason for not-loading bash aliases and the user bashrc
file when starting new bash? It is meant to prevent conflicts?

AFAICT, the reason for messing about with the shell startup was to
force the use of per-mapset history files.

The code which creates the GRASS-specific .bashrc file tries to load
the aliases, but it does so before HOME has been restored, so it
doesn't work.

If you normally use GRASS from the command line, you're probably
better off just forgetting about the whole "startup" thing and putting
the necessary environment settings into your ~/.bashrc.

FWIW, I source a file containing the following from ~/.bash_profile
(which in turn is sourced from ~/.xsession):

#export GISBASE=/opt/grass-7.0.svn
export GISBASE=/usr/local/src/grass/svn/dist.x86_64-unknown-linux-gnu
export GRASS_GNUPLOT='gnuplot -persist'
export GRASS_WIDTH=640
export GRASS_HEIGHT=480
export GRASS_HTML_BROWSER=firefox
export GRASS_PAGER=cat
export GRASS_WISH=wish
export GRASS_PYTHON=python
export GRASS_MESSAGE_FORMAT=plain
export GRASS_VERBOSE=0
export GRASS_TRUECOLOR=TRUE
export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_TRANSPARENT=TRUE
export GRASS_PNG_AUTO_WRITE=TRUE

export PATH="$GISBASE/bin:$GISBASE/scripts:$PATH"
export LD_LIBRARY_PATH="$GISBASE/lib"
export GRASS_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export PYTHONPATH="$GISBASE/etc/python:$PYTHONPATH"
export MANPATH=$MANPATH:$GISBASE/docs/man

export GIS_LOCK=$$
export GRASS_VERSION="7.0.svn"

tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK
export GISRC="$tmp/gisrc"
mkdir "$tmp"
cp ~/.grassrc6 "$GISRC"

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

Vaclav Petras wrote:
> what is the reason for not-loading bash aliases and the
> user bashrc file when starting new bash? It is meant to
> prevent conflicts?

Glynn wrote:

AFAICT, the reason for messing about with the shell startup
was to force the use of per-mapset history files.

The code which creates the GRASS-specific .bashrc file tries
to load the aliases, but it does so before HOME has been
restored, so it doesn't work.

fwiw, for years I have added this to my ~/.grass.bashrc file,
and it has worked fine for the aliases:

. /home/hamish/.bash_aliases

export PS1='GRASS:\W > '
export HISTSIZE=3000
export GRASS_TRUECOLOR=TRUE
export GRASS_PNG_COMPRESSION=9
export GRASS_PAGER=more

# first GRASS instance gets set a low priority
NUMGRASSES=`pgrep -c Init.sh`
if [ "$NUMGRASSES" -le 1 ] ; then
   renice +14 -p $$
else
   NICENESS=`echo $NUMGRASSES | awk '{printf("%0.f", 20 / $1)}'`
   renice +$NICENESS -p $$
fi

The only caveats are that GRASS_ADDON_PATH and (I think)
GRASS_HTML_BROWSER have to be set from your main ~/.bashrc file.

If you normally use GRASS from the command line, you're
probably better off just forgetting about the whole "startup"
thing and putting the necessary environment settings into your
~/.bashrc.

me, I start from the command line, but like the extra cleanup
& whatnot the startup script provides. shrug.

Hamish

Hi Glynn!

Glynn Clements wrote:

#export GISBASE=/opt/grass-7.0.svn
export GISBASE=/usr/local/src/grass/svn/dist.x86_64-unknown-linux-gnu

...

Shouldn't the following:

tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK

be rather: tmp=/tmp/grass7-"`whoami`"-$GIS_LOCK

export GISRC="$tmp/gisrc"
mkdir "$tmp"

and the following:

cp ~/.grassrc6 "$GISRC"

be rather: cp ~/.grass7/rc "$GISRC"

?

Thank you, Nikos

ps- updated the respective Wiki-Page accordingly!
<http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly#Bash_examples_.28GNU.2FLinux.29&gt;

Nikos wrote:

ps- updated the respective Wiki-Page accordingly!
<http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly#Bash_examples_.28GNU.2FLinux.29&gt;

(please create a new section for grass7-development if you like,
or use the trac development wiki, but do not remove relevant
grass6-stable content while it is still the stable release most
users will and should be using.. tx.)

Nikos Alexandris wrote:

> #export GISBASE=/opt/grass-7.0.svn
> export GISBASE=/usr/local/src/grass/svn/dist.x86_64-unknown-linux-gnu
...

Shouldn't the following:

> tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK

be rather: tmp=/tmp/grass7-"`whoami`"-$GIS_LOCK

The name really doesn't matter. GRASS only ever accesses the file via
the GISRC environment variable.

> export GISRC="$tmp/gisrc"
> mkdir "$tmp"

and the following:

> cp ~/.grassrc6 "$GISRC"

be rather: cp ~/.grass7/rc "$GISRC"

Again, it doesn't actually matter unless the same file is supposed to
be used when creating a GRASS session via the startup script.

FWIW, I do have a ~/.grass7/rc file; the timestamp is Feb 2010, which
shows how often I run the startup script.

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

On Friday 15 of February 2013 16:48:46 Hamish wrote:

Nikos wrote:
> ps- updated the respective Wiki-Page accordingly!
> <http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_ex
> plicitly#Bash_examples_.28GNU.2FLinux.29>
(please create a new section for grass7-development if you like,
or use the trac development wiki, but do not remove relevant
grass6-stable content while it is still the stable release most
users will and should be using.. tx.)

Reverted back -- thanks for heads-up!

My justification was/is that this specific set of instructions are targeting
users who (at least think that they) know what they are doing.

Best, N

Nikos Alexandris wrote:

> > #export GISBASE=/opt/grass-7.0.svn
> > export GISBASE=/usr/local/src/grass/svn/dist.x86_64-unknown-linux-gnu
> ...
> Shouldn't the following:
> > tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK

> be rather: tmp=/tmp/grass7-"`whoami`"-$GIS_LOCK

Glynn Clements wrote:

The name really doesn't matter. GRASS only ever accesses the file via
the GISRC environment variable.

o-kay.

[@Hamish] I'll try to simplify the Wiki again.

> > export GISRC="$tmp/gisrc"
> > mkdir "$tmp"

> and the following:
> > cp ~/.grassrc6 "$GISRC"

> be rather: cp ~/.grass7/rc "$GISRC"

Again, it doesn't actually matter unless the same file is supposed to
be used when creating a GRASS session via the startup script.

FWIW, I do have a ~/.grass7/rc file; the timestamp is Feb 2010, which
shows how often I run the startup script.

Thanks, Nikos