help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to use bash alias in emacs compile


From: Pascal J. Bourguignon
Subject: Re: how to use bash alias in emacs compile
Date: Mon, 07 May 2012 22:18:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

"Daniel (Youngwhan)" <breadncup@gmail.com> writes:

> On May 3, 1:35 am, "Pascal J. Bourguignon" <p...@informatimago.com>
> wrote:
>> "Daniel (Youngwhan)" <breadn...@gmail.com> writes:
>> > Hi,
>>
>> > I have alias like this:
>>
>> > alias dm='cd ~/XYZ && ./mycompile.sh'
>>
>> Where do you have it?
>>
>
> The lots of aliases are defined in a file, where is in $HOME/bin, and
> the $PATH has it, too.
>
>> > I typed M-x compile, and tried to run by just typing "dm", but it
>> > doesn't recognize.
>>
>> Try: M-x compile RET C-a C-k bash -i -c dm RET
>>
>
> Yeah, it works!, but if I typed only dm, it doesn't.
>
>> > I searched and some suggest BASH_ENV, so I tried, but not working.
>>
>> man bash explains in details what file it will load and when, but it's
>> complicated.  I put everything in ~/.bashrc
>>
>
> Let me study you've mentioned here, but if you can share your
> experience in detail, it would be appreciated.

In summary, here is what I got from reading the manual:


#    WHEN starting
#     AND ( interactive AND login ) OR ( non-interactive AND --login ) )
#      DO /etc/profile 
#         THEN    ~/.bash_profile 
#         OR ELSE ~/.bash_login
#         OR ELSE ~/.profile
#
#    WHEN starting
#     AND interactive AND NOT login
#      DO ~/.bashrc
#
#    WHEN starting
#     AND NOT interactive
#      DO $BASH_ENV
#
#    WHEN exiting
#     AND login
#      DO ~/.bash_logout

I put everything in ~/.bashrc, and my ~/.profile contains:
------------------------------------------------------------------------
if test -f "$HOME/.bashrc" ; then
    echo "Sourcing $HOME/.bashrc from $HOME/.profile"
        source "$HOME/.bashrc"
fi
------------------------------------------------------------------------
Also, my ~/.bashrc creates ~/.bash_env and loads it.


But notice that bash loads ~/.bashrc when running a bash script
interactively.  From some scripts it may not be a good idea, because
this let the user change the environment (aliases, functions,
environment variables), so it may break some scripts.  (You may want to
use #!/bin/sh instead of #!/bin/bash in those cases).


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]