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

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

Re: Shell aliases as shell-commands


From: Sebastian Tennant
Subject: Re: Shell aliases as shell-commands
Date: Wed, 21 Jan 2009 10:51:26 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Quoth Barry Margolin <address@hidden>:
> In article <address@hidden>,
>  Sebastian Tennant <address@hidden> wrote:
>
>> Quoth Peter Dyballa <address@hidden>:
>> > Am 20.01.2009 um 10:09 schrieb Sebastian Tennant:
>> >
>> >> It's 'M-x shell-command' I'm thinking about.
>> >
>> > Forget it!  Shell-command is not meant for interactive use as in a
>> > shell with aliases and such comfort.
>> 
>> But my aliases are so handy!!! I want them (without having to run an
>> interactive shell), and Emacs can give them to me, I know it can :)
>
> Can you define them as functions instead of aliases?

The issue was over instructing the shell to source my ~/.bashrc (which
contains both aliases and functions).

I mistakenly thought that the way to get a shell to read init files was
to specify a login shell (bash -l -c <command>), but that isn't the way
to do it, rather, you should force interactive behaviour with the '-i'
switch (bash -i -c <command>).  Do this and all your aliases and
functions are to hand.

Here are the two functions I posted to emacs.sources that force
interactive shells and put all your aliases and function defs at your
fingertips.

 http://article.gmane.org/gmane.emacs.sources/3147

The previous post (3146) contains a little bit of explanation but don't
use the code from 3146 or you'll break shell-command (slightly).

If you have lots of aliases and functions you'd like to access via

  M-! <command>

you may like to rebind M-! to interactive-shell-command, like so:

 (global-set-key "M-!" 'interactive-shell-command)

Sebastian





reply via email to

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