[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: |
Tue, 20 Jan 2009 15:40:39 +0000 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) |
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
- Shell aliases as shell-commands, Sebastian Tennant, 2009/01/19
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/19
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/20
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/20
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/20
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/20
- Re: Shell aliases as shell-commands,
Sebastian Tennant <=
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/20
- Re: Shell aliases as shell-commands, Thierry Volpiatto, 2009/01/20
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/20
- Message not available
- Re: Shell aliases as shell-commands, Teemu Likonen, 2009/01/20
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/21
- Message not available
- Re: Shell aliases as shell-commands, Barry Margolin, 2009/01/21
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/21
- Message not available
- Re: Shell aliases as shell-commands, Michael Heerdegen, 2009/01/21
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/21
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/21