Hi there,
I am trying to get my aliases in the GRASS-Shell, preferable from my .bashrc
(or at least a .alias-file).
If started form a bash, GRASS prepares its own .bashrc in the chosen Location
and starts a child shell (= GRASS-Shell) from there, as stated
in 'grass-6.3.cvs/etc/Init.sh'. This Shell knows only the setting from the
newly created .bashrc, so I guess I need to get my aliases in that file.
In line 815 in 'grass-6.3.cvs/etc/Init.sh' a .alias-file is executed if it is
readable. Since the environment variable HOME is set to LOCATION in line 810
it looks for a .alias file in LOCATION and not in the users home directory,
is this intended?
If line 815 would read
echo "test -r ${USERHOME}/.alias && . ${USERHOME}/.alias" >> "$bashrc"
instead of
echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
the user's alias-settings would be carried over to the GRASS-Shell.
It would be even nicer if the GRASS-Startup-Script could parse my .bashrc, but
I have no idea how to achieve that.
Looking forward to comments about the intention of line 815
in 'grass-6.3.cvs/etc/Init.sh' .
Cheers,
Robert
Robert Nuske wrote:
I am trying to get my aliases in the GRASS-Shell, preferable from my .bashrc
(or at least a .alias-file).
If started form a bash, GRASS prepares its own .bashrc in the chosen Location
and starts a child shell (= GRASS-Shell) from there, as stated
in 'grass-6.3.cvs/etc/Init.sh'. This Shell knows only the setting from the
newly created .bashrc, so I guess I need to get my aliases in that file.
If you create a file called ~/.grass.bashrc, its contents will be
appended to the temporary .bashrc file. If you put ". ~/.bashrc" into
that file, it should source your original ~/.bashrc file ($HOME should
have been restored at that point).
In line 815 in 'grass-6.3.cvs/etc/Init.sh' a .alias-file is executed if it is
readable. Since the environment variable HOME is set to LOCATION in line 810
it looks for a .alias file in LOCATION and not in the users home directory,
is this intended?
If line 815 would read
echo "test -r ${USERHOME}/.alias && . ${USERHOME}/.alias" >> "$bashrc"
instead of
echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
the user's alias-settings would be carried over to the GRASS-Shell.
It would be even nicer if the GRASS-Startup-Script could parse my .bashrc, but
I have no idea how to achieve that.
Looking forward to comments about the intention of line 815
in 'grass-6.3.cvs/etc/Init.sh' .
Probably someone forgot that $HOME hadn't been reverted at that point.
Reverting $PATH and $HOME should probably come first. Actually, I'm
not sure that there's any need to mess with $HOME; AFAICT, it was done
so that the .bash_history file would get stored in the mapset, but
that can be achieved by setting HISTFILE.
More generally, Init.sh is somewhat over-engineered IMHO. It contains
lots of hacks which someone presumably thought were a good idea;
others may feel differently about them.
--
Glynn Clements <glynn@gclements.plus.com>
Thanks Glynn for your answer!
> If started form a bash, GRASS prepares its own .bashrc in the chosen
> Location and starts a child shell (= GRASS-Shell) from there, as stated
> in 'grass-6.3.cvs/etc/Init.sh'. This Shell knows only the setting from
> the newly created .bashrc, so I guess I need to get my aliases in that
> file.
If you create a file called ~/.grass.bashrc, its contents will be
appended to the temporary .bashrc file.
Yes, I've seen this, but felt repelled to keep two lists of aliases.
If you put ". ~/.bashrc" into
that file, it should source your original ~/.bashrc file ($HOME should
have been restored at that point).
yep, that looks like a solution. I was so fixated on the ~/.alias in Init.sh
that I wasn't looking that way.
> In line 815 in 'grass-6.3.cvs/etc/Init.sh' a .alias-file is executed if
> it is readable. Since the environment variable HOME is set to LOCATION in
> line 810 it looks for a .alias file in LOCATION and not in the users home
> directory, is this intended?
>
> If line 815 would read
> echo "test -r ${USERHOME}/.alias && . ${USERHOME}/.alias" >>
> "$bashrc" instead of
> echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
> the user's alias-settings would be carried over to the GRASS-Shell.
>
> It would be even nicer if the GRASS-Startup-Script could parse my
> .bashrc, but I have no idea how to achieve that.
>
> Looking forward to comments about the intention of line 815
> in 'grass-6.3.cvs/etc/Init.sh' .
Probably someone forgot that $HOME hadn't been reverted at that point.
Reverting $PATH and $HOME should probably come first. Actually, I'm
not sure that there's any need to mess with $HOME; AFAICT, it was done
so that the .bash_history file would get stored in the mapset, but
that can be achieved by setting HISTFILE.
So, am I right that this line is useless in its current state and should be
changed or taken out?
I would prefer if it would source the .alias in the users home directory.
cheers,
robert
Robert Nuske wrote:
> > Looking forward to comments about the intention of line 815
> > in 'grass-6.3.cvs/etc/Init.sh' .
>
> Probably someone forgot that $HOME hadn't been reverted at that point.
> Reverting $PATH and $HOME should probably come first. Actually, I'm
> not sure that there's any need to mess with $HOME; AFAICT, it was done
> so that the .bash_history file would get stored in the mapset, but
> that can be achieved by setting HISTFILE.
So, am I right that this line is useless in its current state and should be
changed or taken out?
Yes.
I would prefer if it would source the .alias in the users home directory.
That's potentically problematic.
If the user puts ". ~/.bashrc" into their ~/.grass.bashrc file, and
their ~/.bashrc sources ~/.alias, then having init.sh source ~/.alias
would result in it getting read twice.
Having Init.sh set up a .bashrc file is one thing (that name is built
into bash), but the ~/.alias file is something that specific
distribution vendors have cooked up for use by their default ~/.bashrc
(etc) scripts. If you aren't using such a platform, ~/.alias might not
even contain bash code.
--
Glynn Clements <glynn@gclements.plus.com>