zsh-users
 help / color / mirror / code / Atom feed
From: Dan Nelson <dnelson@emsphone.com>
To: Bart Schaefer <schaefer@candle.brasslantern.com>
Cc: zsh-users@sunsite.auc.dk
Subject: Re: Bindkey + PageUp/PageDown keys
Date: Wed, 13 Dec 2000 00:22:30 -0600	[thread overview]
Message-ID: <20001213002230.A16743@dan.emsphone.com> (raw)
In-Reply-To: <1001213050341.ZM11148@candle.brasslantern.com>; from "Bart Schaefer" on Wed Dec 13 05:03:41 GMT 2000

In the last episode (Dec 13), Bart Schaefer said:
> On Dec 12,  1:38am, Geoff Wing wrote:
> } Subject: Re: Bindkey + PageUp/PageDown keys
> }
> } Oliver Grimm <grimm@particle.phys.ethz.ch> typed:
> } :In xterm, they are called 'Prior', 'Next', etc. but how do I use
> } :this with bindkey ?
> } 
> } Your terminal emulator (xterm) will translate the Prior (PageUp)
> } and Next (PageDown) keys into a character sequence - usually an
> } escape sequence (i.e. the first character in the sequence is an
> } escape character).
> 
> I realize that naming the file after $TERM is not quite accurate
> because e.g. one can use an xterm with with just about any kind of
> keyboard.  On the other hand, the same keyboard can generate
> different sequences in different terminal emulators.  If someone has
> a better idea for the file naming convention, I'd be happy to hear
> it.

It should be perfectly accurate, since TERM specifies not only output
escape sequences but input sequences as well; that's what all the
capabilities starting with k are.  If you have two terminal emulators
that send different ESC sequences for different keys, they should have
different TERM types (or you should submit a bug report to the author
of the one that's sending incorrect codes).

I use the following function in /etc/zshrc.  It's a wrapper around
bindkey that takes an extra argument - the termcap code to bind an
action to.  $2 is only used if there is no entry for that code.  I've
had this in my zshrc for so long I honestly have no idea what zsh's
default settings are for the keys I replace :)

# usage: bindtc <cap> <fallback> <zsh-command>
bindtc () 
{
	local keyval=$(echotc "$1" 2>&-)
	bindkey "${keyval:-$2}" "$3"
}

# Let backtab cycle through completions in reverse
bindtc bt "^[[Z" reverse-menu-complete

# Bindings for PGUP, PGDN, HOME, END
bindtc kP "^[[I" history-beginning-search-backward
bindtc kN "^[[G" history-beginning-search-forward
bindtc kh "^[[H" beginning-of-line
bindtc kH "^[[F" end-of-line

# Bindings for UP, DOWN, LEFT, RIGHT
bindtc ku "^[[A" up-line-or-history
bindtc kd "^[[B" down-line-or-history
bindtc kr "^[[C" forward-char
bindtc kl "^[[D" backward-char

-- 
	Dan Nelson
	dnelson@emsphone.com


      reply	other threads:[~2000-12-13  6:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-11 12:14 Oliver Grimm
2000-12-12  1:38 ` Geoff Wing
2000-12-13  5:03   ` Bart Schaefer
2000-12-13  6:22     ` Dan Nelson [this message]

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=20001213002230.A16743@dan.emsphone.com \
    --to=dnelson@emsphone.com \
    --cc=schaefer@candle.brasslantern.com \
    --cc=zsh-users@sunsite.auc.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).