[Top][All Lists]

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

Re: tramp (; feature request: easy escape for `M-!' to run c

From: Michael Albinus
Subject: Re: tramp (; feature request: easy escape for `M-!' to run command locally
Date: Sun, 11 Sep 2016 13:19:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

[Sorry, sent too early. Next try :-) ]

Dave Abrahams <address@hidden> writes:

> Hi Michael,

Hi Dave,

> When working primarily remotely through TRAMP, I keep finding myself
> wanting to run a command on my local machine, so I have to `C-x C-f
> <delete-everything>~' first, which messes up my window layout, etc.
> It would be awesome if I could `C-u C-u M-!' (or something) and get the
> local command without jumping through hoops.  Or is there a better way?

M-! invokes `shell-command'. It does not care too much about the prefix
argument C-u, its docstrings says

--8<---------------cut here---------------start------------->8---
Execute string COMMAND in inferior shell; display output, if any.
With prefix argument, insert the COMMAND’s output at point.
--8<---------------cut here---------------end--------------->8---

It might be a good idea to extend the prefix mechanism in order to allow
changing `default-directory', but this is a feature request. You might
ask for this by writing an Emacs bug report.

Alternatively, you could write an own function, and bind it to your own
key. Something like (untested)

--8<---------------cut here---------------start------------->8---
(defun my-shell-command (command &optional output-buffer error-buffer)
  "My own implementation of `shell-command', running on local host."
  (interactive "i")
  (let ((default-directory (expand-file-name "~/")))
    (if (called-interactively-p 'any)
        (call-interactively 'shell-command)
      (shell-command command output-buffer error-buffer))))

(define-key global-map "\M-*" 'my-shell-command)
--8<---------------cut here---------------end--------------->8---

> Thanks,
> Dave

Best regards, Michael.

reply via email to

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