From: Sebastian Tennant <sebyte@smolny.plus.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Shell aliases as shell-commands
Date: Tue, 20 Jan 2009 15:40:39 +0000 [thread overview]
Message-ID: <hc3um1e0.fsf@vps203.linuxvps.org> (raw)
In-Reply-To: 85A4F069-4A99-4B9E-AD09-4F2C860A9D83@Web.DE
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)")))))
Thanks to all for their suggestions.
Sebastian
next prev parent reply other threads:[~2009-01-20 15:40 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 [this message]
2009-01-20 16:43 ` Peter Dyballa
2009-01-20 17:09 ` Thierry Volpiatto
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=hc3um1e0.fsf@vps203.linuxvps.org \
--to=sebyte@smolny.plus.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.
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.