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

Re: HPUX (was Re: vi command line editing)



In the last episode (Mar 25), Andrew Main said:
> Shawn Leas wrote:
> >bindkey -s "^[OA" "^[ka"
> >bindkey -s "^[OB" "^[ja"
> >bindkey -s "^[OD" "^[ha"
> >bindkey -s "^[OC" "^[la"
> 
> That's a terminal issue.  Some terminals send "^[OA" instead of "^[[A".
> Of course, a lot of terminals send sequences completely different from
> these, but zsh should probably recognise both of these sets by default.

My soution (adjust to your needs):

# usage: bindtc <cap> <default> <zsh-command>
# Binds a termcap entry <cap> to a command.  If the termcap string does 
# not exist, use <default>
bindtc ()
{
    local keyval=$(echotc "$1" 2>&-)
    bindkey "${keyval:-$2}" "$3"
}

# 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