Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Macro's
- X-seq: zsh-users 11305
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: fREW <frioux@xxxxxxxxx>
- Subject: Re: Macro's
- Date: Thu, 15 Mar 2007 11:44:16 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <fb3648c60703142111g5407c97v9473b00ccf3d7ce8@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <fb3648c60703142111g5407c97v9473b00ccf3d7ce8@xxxxxxxxxxxxxx>
fREW wrote:
> I was reading the book From Bash to Z Shell and it mentioned that
> macros are possible with Bash but not zsh, so I did a search on Google
> and found a patch for readline style macros that had been submitted
> just shy of TEN YEARS ago. Is there any possibility that such a
> feature still may be added? Or will it have to be either a hack or
> too much reworking to happen?
It's the sort of thing that can be written as a custom editor command
(see chapter 14).
As a very quick attempt to make something work, try the following:
start-kbd-macro() {
local macro
while
read -k 1
[[ $REPLY != \) ]] || (( ##$macro[-1] != 24 )); do
macro+="$REPLY"
done
bindkey -s '^Xe' "$macro[1,-2]"
}
zle -N start-kbd-macro
bindkey '^X)' start-kbd-macro
This can be improved in many ways. It doesn't pass the keys pressed on
to the line editor so they don't work as you record the macro. It
doesn't display a message to tell you that macro recording is in
progress. It has also hard coded the key for ending macro recording.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author