[OS X Emacs] kill-ring and minibuffer

Jack Repenning jrepenning at collab.net
Thu Jan 27 12:47:34 EST 2011


On Jan 27, 2011, at 6:26 AM, Marinos Koutsomichalis wrote:

> M-!
> pwd
> 
> how can I append the result in the kill-ring for further use ?

Do you mean to do this every time you use M-!, or only occasionally? Presuming the latter, then this function would do it:

(defun remember-shell-command-output nil
  (interactive)
  (save-excursion
    (set-buffer "*Shell Command Output*")
    (kill-ring-save (point-min) (point-max))))

You might bind that to M-C-!, and think of it as "yeah, grab that."

(global-set-key [(ctrl meta !)] 'remember-shell-command-output)

A "secret" here is that the text you're thinking of isn't actually in the minibuffer (a special, largely hidden buffer used for command input), but rather in the buffer "*Shell Command Output*", which when it's only one line long is temporarily displayed in the area where the Minibuffer is normally displayed (though if the output is multi-line, it's displayed elsewhere -- try "M-! ls" for example).





More information about the MacOSX-Emacs mailing list