[GRASS-user] loss of bash aliases

Hi,

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?

Cheers,

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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?

Cheers,

Dylan

What happens if you copy your alias into ~/.grass_bashrc?

~ Eric.

What happens if you copy your alias into ~/.grass_bashrc?

Sorry, that should have been ~/.grass.bashrc.

~ Eric.

On Wednesday 05 March 2008, Patton, Eric wrote:

~/.grass_bashrc

nope!

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

On Wednesday 05 March 2008, Patton, Eric wrote:

.grass.bashrc

that did it! thanks.

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

Dylan Beaudette <dylan.beaudette@gmail.com> writes:

>> .grass.bashrc

> that did it! thanks.

  It may worth to ``include'' ~/.bashrc from ~/.grass.bashrc, e. g.:

--cut: .grass.bashrc--
if [ -r "$HOME"/.bashrc ]; then
    . "$HOME"/.bashrc
fi
--cut: .grass.bashrc--

  (Just as ~/.bashrc typically sources /etc/bashrc.)

  This way, you should get all the aliases, Shell variables &
  functions defined in ~/.bashrc defined in GRASS as well. (But
  you'll need to be sure that your ~/.bashrc won't interfere with
  GRASS.)

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

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

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

[...]

Philipp Steigenberger wrote:

why does the test refer to .alias?

AFAIK it is just historically a common place to put them. I have no
idea if it conforms to SUS, but it seems to me cleaner than having a
huge pile of aliases in ~/.bashrc and at least once upon a time was
common.
shrug.

As I wrote in the attached mail the
bash-alias-file should be .bash_aliases

In .grass.bashrc you can call it whatever you like.

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.

because "~" has been redefined to be your mapset dir...?
try in your .grass.bashrc calling it with the full path to the file,
/home/you/.bash_aliases

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

$USERHOME is not exported from Init.sh so cannot be seen in the child
..grass.bashrc script.

Greets to the other side of the globe

& back again,
Hamish

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Hamish:

FWIW, my .grass.bashrc has:

.. /home/hamish/.alias
export HISTSIZE=3000

Thank you! I was trying to think of what that variable name was to extend
my mapset history beyond 500 records.

# 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

What is the result of this - that all Grass processes get a low priority
compared to the rest of the OS?

~ Eric.