[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shell aliases as shell-commands
From: |
Thierry Volpiatto |
Subject: |
Re: Shell aliases as shell-commands |
Date: |
Tue, 20 Jan 2009 18:09:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
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
- 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, 2009/01/20
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/20
- Re: Shell aliases as shell-commands,
Thierry Volpiatto <=
- 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
- Re: Shell aliases as shell-commands, Sebastian Tennant, 2009/01/21
- Re: Shell aliases as shell-commands, Peter Dyballa, 2009/01/21