zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh-users <zsh-users@sunsite.dk>
Subject: Re: bindkey and widgets
Date: Sun, 21 Mar 2004 17:01:57 +0000	[thread overview]
Message-ID: <1040321170157.ZM25009@candle.brasslantern.com> (raw)
In-Reply-To: <20040321143156.GA31236@fargo>

On Mar 21,  3:31pm, David ( Text in unknown character set ISO-8859-15  wrote:
} 
} It is possible to map the "Ctrl+RePag" combination using bindkey?

Only if your terminal or emulator sends a different escape sequence for
the RePag key when "modifier" keys like shift/ctrl/meta/alt are pressed.

} '^\e[5~' and '\C-\e[5~'

No.  \e[5~ is the four-character sequence (escape left-bracket five tilde)
that is sent when the unmodified RePag key is pressed.  For function keys
that send multi-character sequences, pressing the control key often has
no effect, but if it has any effect at all it will be to cause another,
different multi-character sequence to be sent.

So you need to find out what that sequence is.  The easiest way may be
to type Ctrl+v (which usually means "quote next character") and then
Ctrl+RePag and see what appears.  If it looks like ^[[5~ (^[ is another
way to write \e), then your keyboard and/or terminal emulator does not
distinguish the ctrl modifier for function keys.  If it looks different,
then that is the sequence you use for bindkey.

It may be possible to program your terminal emulator to recognize ctrl
with function keys, but that's beyond what I'm prepared to explain here.

} On the other hand, how can i map one action with two widgets?. When
} the Control-K combination is pressed, i want two widgets to be executed,
} namely kill-line and end-of-history.

Creating a widget is probably the best way because it doesn't depend on
any other bindings.  However, you can use "bindkey -s".

First, assuming Ctrl+k is presently bound to kill-line, you have to make
a new binding for kill-line.  Escape left-curly-bracket is an unlikely
combination and not usually bound, so:

    bindkey '\e{' kill-line

Then you need a binding for end-of-history, which isn't attached to a key
by default.  I'll choose escape right-curly-bracket for this example:

    bindkey '\e}' end-of-history

Finally, rebind Ctrl+k with:

    bindkey -s '\C-k' '\e{\e}'

The widget, on the other hand, would look like this:

    kill-line-and-end-history () {
      zle .kill-line && zle .end-of-history
    }
    zle -N kill-line kill-line-and-end-history

That actually renames kill-line to your new widget, so all bindings for
kill-line now include jumping to the end of the history.  If you want to
change Ctrl+k only, use:

    zle -N kill-line-and-end-history
    bindkey '\C-k' kill-line-and-end-history


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


  reply	other threads:[~2004-03-21 17:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-21 14:31 David Gómez
2004-03-21 17:01 ` Bart Schaefer [this message]
2004-03-21 21:26   ` David Gómez
2004-03-21 18:18 ` DervishD
2004-03-21 21:51   ` David Gómez
2004-03-22 14:52     ` DervishD
2004-03-22 16:02       ` David Gómez
2004-03-22 17:53         ` Eric Mangold

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1040321170157.ZM25009@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).