* how to use bash alias in emacs compile
@ 2012-05-02 21:28 Daniel (Youngwhan)
2012-05-02 21:42 ` Peter Dyballa
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Daniel (Youngwhan) @ 2012-05-02 21:28 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I have alias like this:
alias dm='cd ~/XYZ && ./mycompile.sh'
I typed M-x compile, and tried to run by just typing "dm", but it
doesn't recognize.
I searched and some suggest BASH_ENV, so I tried, but not working.
I'm using GNU emacs 23.4.1 running on Linux (Ubuntu 2.6.38 kernel),
and GNU Bash version is 4.1.5.
When I type "alias" in M-x compile, it shows dm in right way, but it
looks the "compile" in emacs does not recognize bash alias.
Is there anyone who resolve this problem? Or it is impossible to use
bash alias in emacs compile.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-02 21:28 how to use bash alias in emacs compile Daniel (Youngwhan)
@ 2012-05-02 21:42 ` Peter Dyballa
2012-05-02 22:55 ` Barry Margolin
2012-05-03 8:35 ` Pascal J. Bourguignon
2 siblings, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2012-05-02 21:42 UTC (permalink / raw)
To: Daniel (Youngwhan); +Cc: help-gnu-emacs
Am 02.05.2012 um 23:28 schrieb Daniel (Youngwhan):
> When I type "alias" in M-x compile, it shows dm in right way, but it
> looks the "compile" in emacs does not recognize bash alias.
Maybe you should use tcsh – here aliases work.
Anyway, maybe it plays a role in which of the many RC files bash can use you put the alias definitions, because there are some for interactive and some for non-interactive use. ~/.bashrc should be a good choice.
--
Greetings
Pete
My sister opened a computer store in Hawaii. She sells C shells down by the seashore.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-02 21:28 how to use bash alias in emacs compile Daniel (Youngwhan)
2012-05-02 21:42 ` Peter Dyballa
@ 2012-05-02 22:55 ` Barry Margolin
2012-05-03 8:35 ` Pascal J. Bourguignon
2 siblings, 0 replies; 7+ messages in thread
From: Barry Margolin @ 2012-05-02 22:55 UTC (permalink / raw)
To: help-gnu-emacs
In article
<a0a22d31-830a-4488-96c8-2846e47fcff4@v1g2000yqm.googlegroups.com>,
"Daniel (Youngwhan)" <breadncup@gmail.com> wrote:
> Hi,
>
> I have alias like this:
>
> alias dm='cd ~/XYZ && ./mycompile.sh'
>
> I typed M-x compile, and tried to run by just typing "dm", but it
> doesn't recognize.
>
> I searched and some suggest BASH_ENV, so I tried, but not working.
>
> I'm using GNU emacs 23.4.1 running on Linux (Ubuntu 2.6.38 kernel),
> and GNU Bash version is 4.1.5.
>
> When I type "alias" in M-x compile, it shows dm in right way, but it
> looks the "compile" in emacs does not recognize bash alias.
>
> Is there anyone who resolve this problem? Or it is impossible to use
> bash alias in emacs compile.
Have you tried changing your alias into a script that can be found via
your $PATH?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-02 21:28 how to use bash alias in emacs compile Daniel (Youngwhan)
2012-05-02 21:42 ` Peter Dyballa
2012-05-02 22:55 ` Barry Margolin
@ 2012-05-03 8:35 ` Pascal J. Bourguignon
2012-05-07 19:48 ` Daniel (Youngwhan)
2 siblings, 1 reply; 7+ messages in thread
From: Pascal J. Bourguignon @ 2012-05-03 8:35 UTC (permalink / raw)
To: help-gnu-emacs
"Daniel (Youngwhan)" <breadncup@gmail.com> writes:
> Hi,
>
> I have alias like this:
>
> alias dm='cd ~/XYZ && ./mycompile.sh'
Where do you have it?
> 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
> 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
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-03 8:35 ` Pascal J. Bourguignon
@ 2012-05-07 19:48 ` Daniel (Youngwhan)
2012-05-07 20:04 ` ken
2012-05-07 20:18 ` Pascal J. Bourguignon
0 siblings, 2 replies; 7+ messages in thread
From: Daniel (Youngwhan) @ 2012-05-07 19:48 UTC (permalink / raw)
To: help-gnu-emacs
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.
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
Thank you!
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-07 19:48 ` Daniel (Youngwhan)
@ 2012-05-07 20:04 ` ken
2012-05-07 20:18 ` Pascal J. Bourguignon
1 sibling, 0 replies; 7+ messages in thread
From: ken @ 2012-05-07 20:04 UTC (permalink / raw)
To: help-gnu-emacs
On 05/07/2012 03:48 PM Daniel (Youngwhan) wrote:
> 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.
Yes, ~/.bashrc is the place to put aliases... because then they are
loaded whenever you log in. If this isn't the behavior you want, then
you can put them somewhere else, e.g., in ~/bin/aliases, but then you'll
have to invoke them yourself. This can be done with either of these
commands:
source ~/bin/aliases
or
. ~/bin/aliases
(Note that "~/bin/aliases" is an example name I made up. Just about any
normal filename can be given.)
If you edit ~/.bashrc, including new aliases in it, you can use the same
commands as above to read those new aliases into the current environment
with:
source ~/.bashrc
or
. ~/.bashrc
Then you don't have to log out and then log back in to put your new
aliases into effect.
hth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use bash alias in emacs compile
2012-05-07 19:48 ` Daniel (Youngwhan)
2012-05-07 20:04 ` ken
@ 2012-05-07 20:18 ` Pascal J. Bourguignon
1 sibling, 0 replies; 7+ messages in thread
From: Pascal J. Bourguignon @ 2012-05-07 20:18 UTC (permalink / raw)
To: help-gnu-emacs
"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 {}.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-05-07 20:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-02 21:28 how to use bash alias in emacs compile Daniel (Youngwhan)
2012-05-02 21:42 ` Peter Dyballa
2012-05-02 22:55 ` Barry Margolin
2012-05-03 8:35 ` Pascal J. Bourguignon
2012-05-07 19:48 ` Daniel (Youngwhan)
2012-05-07 20:04 ` ken
2012-05-07 20:18 ` Pascal J. Bourguignon
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.