help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How can I bind a shell command to a key?


From: Mathias Dahl
Subject: Re: How can I bind a shell command to a key?
Date: Mon, 22 May 2006 09:01:32 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)

"LUK" <700MHz@gmail.com> writes:

> Hi, I want to bind a shell command "find . -type f -name "*" -print |
> etags -" 
> to"F1",
> what should I write in ".emacs"?

You could record a keyboard macro, give that a name and insert it into
your .emacs file or you could write a simple elisp function; then you
could bind F1 to one of those.

Keyboard macro approach:

C-x (
M-!
type shell command here
C-x )

Now the macro is defined. Give it a name:

M-x name-last-kbd-macro RET my-macro-name RET

Insert it into your .emacs:

M-x insert-kbd-macro RET my-macro-name RET

Bind F1 to the macro:

(global-set-key [F1] 'my-macro-name)

Function approach:

(defun my-shell-command ()
  (interactive)
  (shell-command "type shell command here"))

And then:

(global-set-key [F1] 'my-shell-command)

Remember that in the function approach you have to quote the quotation
marks with \. This:

"*" should be written \"*\" inside the string.

Good luck!


reply via email to

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