From: Mathias Dahl <brakjoller@gmail.com>
Subject: Re: How can I bind a shell command to a key?
Date: Mon, 22 May 2006 09:01:32 +0200 [thread overview]
Message-ID: <u3bf2a6gj.fsf@gmail.com> (raw)
In-Reply-To: 1148266311.755841.225520@g10g2000cwb.googlegroups.com
"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!
next prev parent reply other threads:[~2006-05-22 7:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-22 2:51 How can I bind a shell command to a key? LUK
2006-05-22 7:01 ` Mathias Dahl [this message]
2006-05-22 7:02 ` Burton Samograd
2006-05-22 7:04 ` Ye Wenbin
2006-05-22 7:44 ` LUK
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u3bf2a6gj.fsf@gmail.com \
--to=brakjoller@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).