Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bash-like PgUp/PdDown reverse search?

In the last episode (Aug 24), Peter Stephenson said:
> "Richard Hartmann" wrote:
> > I have been unable to make PgUp / PgDown act like Bash's
> > reverse search. I.e., you enter some string and then press
> > PgUp / PgDown to search for commands that start with this
> > string.
> bindkey '^[[5~' history-beginning-search-backward
> bindkey '^[[6~' history-beginning-search-forward
> Use "read" with no arguments to verify that's what your PageUp and
> PageDown are sending; hit ^C to exit.

I use a helper function in my zshrc to set up all my bindings:

# usage: bindtc <cap> <default> <zsh-command>
bindtc () 
	setopt localoptions
	local keyval=$(echotc "$1" 2>&-)
	[[ $keyval == "no" ]] && keyval=""
	bindkey "${keyval:-$2}" "$3"

# 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

	Dan Nelson

Messages sorted by: Reverse Date, Date, Thread, Author