[GRASS-user] loss of bash aliases

Philipp Steigenberger userlist at online.de
Thu Mar 6 03:06:37 EST 2008


Hamish schrieb:
> Dylan:
>>> I have the following line in my .bashrc:
>>>
>>> alias l='ls -lh --color=auto'
>>>
>>> After I start a GRASS session this alias seems to go away. Is
>>> there anyway to respect user customization (i.e. .bashrc)
>>> when initializing GRASS?
>>> Or is this a user-related error?
> 
> GRASS's Init.sh does special tricks with $HOME and $bashrc so you can
> save your command history, etc., for each mapset.
> 
> Then it tries to do:
>   echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
> 
> but at that point "$HOME" is already redefined so the real
> /home/you/.alias is not the one it looks for there?
> Fix with "s/~/$USERHOME/" ??
> 
> (that bit of the code is a mess, I don't like to touch it)
> (history file better handled with $HISTFILE ? see g.mapset warning)
> 
> 
> Eric:
>> What happens if you copy your alias into ~/.grass.bashrc?
> 
> yes that works.
> 
> 
> FWIW, my .grass.bashrc has:
> 
> .. /home/hamish/.alias
> export HISTSIZE=3000
> 
> # first GRASS instance gets set a low priority (because we can)
> NUMGRASSES=`pgrep -c Init.sh`
> if [ "$NUMGRASSES" -le 1 ] ; then
>    renice +17 -p $$
> else
>    NICENESS=`echo $NUMGRASSES | awk '{printf("%0.f", 20 / $1)}'`
>    renice +$NICENESS -p $$
> fi
> 
> 
> 
> Hamish

Hamish,
why does the test refer to .alias? As I wrote in the attached mail the 
bash-alias-file should be .bash_aliases

And what I don't understand either, not even if in the .grass.bashrc is 
defined

if [ -f ~/.bash_aliases ]; then
     . ~/.bash_aliases
fi

the aliases work in grass.

... oh now I understand, do I? Do I have to change this entry in

if [ -f $USERHOME/.bash_aliases ]; then
     . $USERHOME/.bash_aliases
fi

???

No... does not work ;o(

I have this solution to change the Init.sh (see below). But it isn't a 
good one. I hope for a better one with only one alias-definition-file.

Greets to the other side of the globe
cheers
Philipp


Philipp Steigenberger wrote at 03/04/08 11:10
Subject: [GRASS-user] .bash_aliases doesn't work in GRASS & Start 
without	g.gui
> Hi
> 
> I noticed that my .bash_aliases is not affected when GRASS starts. I 
> have a .grass.bashrc which is almost the same as the regular one. I want 
> to have only one aliases-file, therefore I don't want to copy the aliases 
> in the .grass.bashrc.
> 
> in the Init.sh in line 939 the test is
> 
>     echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
> 
> but the aliases files name which the .bashrc suggests to use is .bash_aliases
> 
> # You may want to put all your additions into a separate file like
> # ~/.bash_aliases, instead of adding them here directly.
> 
> My solution to get all my aliases is to change the Init.sh every time I 
> update my svn in line 948 where I insert the following lines:
> 
>  if [ -r "$USERHOME/.bash_aliases" ]
>     then
>         cat "$USERHOME/.bash_aliases" >> "$bashrc"
>     fi
> 
> Is there another way?
> 
> Maybe somebody may change the Init.sh for better acting
> 
[...]




More information about the grass-user mailing list