From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Shell aliases as shell-commands
Date: Tue, 20 Jan 2009 18:09:46 +0100 [thread overview]
Message-ID: <87skndewf9.fsf@tux.homenetwork> (raw)
In-Reply-To: hc3um1e0.fsf@vps203.linuxvps.org
Sebastian Tennant <sebyte@smolny.plus.com> writes:
> Quoth Peter Dyballa <Peter_Dyballa@Web.DE>:
>> So make the shell used an interactive login shell! The variable
>> shell-command-switch seems to be a good option to achieve this, just
>> look into simple.el.
>
> The key word in that sentence is _interactive_. I was labouring under
> the mistaken assumption that requesting a login shell was the way to
> source my ~/.bashrc (via my ~/.profile), but it turns out the '-i'
> switch is what's required.
>
> ---------------- ~/.bashrc ----------------
> alias ll="ls -al"
> ---------------- ~/.bashrc ----------------
>
> $ bash -l -c ll
> bash: ll: command not found
>
> $ bash -i -c ll
> [...] # success!
>
> shell-command as it stands will not suffice because shell-command-switch
> can only hold a single switch (and here I need two; -i and -c) but I
> never expected to be able to use shell-command directly anyway.
>
> Here's my function at last (which I've chosen to call
> interactive-shell-command because you're not restricted to using
> aliases:
>
> (defun interactive-shell-command (command)
> (interactive "sCommand: ")
> (set-buffer (get-buffer-create "*Shell Command Output*"))
> (erase-buffer)
> (let ((exit-code (call-process "/bin/bash" nil t t "-i" "-c" command)))
> (if (> (buffer-size) 0)
> (display-buffer (current-buffer))
> (when (eq exit-code 0)
> (kill-buffer nil)
> (message "(Shell command succeeded with no output)")))))
>
Have a look also at M-x eshell-command, you will have alias and
completion on filenames.
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
next prev parent reply other threads:[~2009-01-20 17:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-19 21:11 Shell aliases as shell-commands Sebastian Tennant
2009-01-19 22:02 ` Peter Dyballa
2009-01-20 9:09 ` Sebastian Tennant
2009-01-20 9:38 ` Peter Dyballa
2009-01-20 10:18 ` Sebastian Tennant
2009-01-20 11:43 ` Peter Dyballa
2009-01-20 15:40 ` Sebastian Tennant
2009-01-20 16:43 ` Peter Dyballa
2009-01-20 17:09 ` Thierry Volpiatto [this message]
2009-01-20 18:03 ` Sebastian Tennant
[not found] ` <mailman.5330.1232446602.26697.help-gnu-emacs@gnu.org>
2009-01-20 11:02 ` Teemu Likonen
2009-01-20 11:10 ` Sebastian Tennant
2009-01-21 5:46 ` Barry Margolin
2009-01-21 10:51 ` Sebastian Tennant
2009-01-21 10:40 ` Michael Heerdegen
2009-01-21 15:26 ` Sebastian Tennant
2009-01-21 15:49 ` Peter Dyballa
2009-01-21 17:07 ` Sebastian Tennant
2009-01-21 18:26 ` Peter Dyballa
[not found] ` <mailman.5445.1232552977.26697.help-gnu-emacs@gnu.org>
2009-01-22 11:52 ` Michael Heerdegen
2009-01-22 13:51 ` Peter Dyballa
2009-01-22 20:26 ` Sebastian Tennant
2009-01-22 13:57 ` Thierry Volpiatto
[not found] ` <mailman.5510.1232633053.26697.help-gnu-emacs@gnu.org>
2009-01-22 17:55 ` Michael Heerdegen
2009-01-22 20:35 ` Sebastian Tennant
[not found] ` <mailman.5443.1232551479.26697.help-gnu-emacs@gnu.org>
2009-02-17 15:14 ` David Combs
2009-02-17 23:18 ` Peter Dyballa
[not found] ` <mailman.5332.1232449359.26697.help-gnu-emacs@gnu.org>
2009-02-17 15:08 ` David Combs
[not found] <mailman.5279.1232399379.26697.help-gnu-emacs@gnu.org>
2009-01-19 22:53 ` Chetan
2009-01-20 9:07 ` Sebastian Tennant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87skndewf9.fsf@tux.homenetwork \
--to=thierry.volpiatto@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).