Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bindkey + PageUp/PageDown keys
- X-seq: zsh-users 3564
- From: Dan Nelson <dnelson@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: Bindkey + PageUp/PageDown keys
- Date: Wed, 13 Dec 2000 00:22:30 -0600
- Cc: zsh-users@xxxxxxxxxxxxxx
- In-reply-to: <1001213050341.ZM11148@xxxxxxxxxxxxxxxxxxxxxxx>; from "Bart Schaefer" on Wed Dec 13 05:03:41 GMT 2000
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <Pine.LNX.4.21.0012111309170.2380-100000@xxxxxxxxxxxxxxx> <slrn93b0c7.e8m.mason@xxxxxxxxxxxxxxxxxxxxx> <1001213050341.ZM11148@xxxxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author