You are not logged in.

#1 2012-10-01 20:31:41

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,445
Website

Keybinding problem in zsh Home/End [Solved but dunno why]

According to the wiki, I need only add the following to my ~/.zshrc to get my Home/End keys to work properly but I am need seeing the desired effect.

Currently:

[Home] = H
[End] = F

What am I doing wrong?

$ cat ~/.zshrc

[[ -z "$PS1" ]] && return
[[ -f /etc/profile ]] && . /etc/profile

for i in functions aliases zsh ; do [[ -f $HOME/.$i ]] && . $HOME/.$i ; done

PATH=$PATH:$HOME/bin

autoload -U compinit
compinit -i

PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[white]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) %#%{$reset_color%} '

TERM=xterm-256color
bindkey -v # set vim bindings

bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[4~" end-of-line # End
bindkey "\e[5~" beginning-of-history # PageUp
bindkey "\e[6~" end-of-history # PageDown
bindkey "\e[2~" quoted-insert # Ins
bindkey "\e[3~" delete-char # Del
bindkey "\e[A" history-beginning-search-backward
bindkey "\e[B" history-beginning-search-forward

Last edited by graysky (2012-10-01 20:58:41)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2012-10-01 20:58:07

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,445
Website

Re: Keybinding problem in zsh Home/End [Solved but dunno why]

I still do not understand why, but the following code in my ~/.zshrc fixes this problem so I guess this thread is [solved].

... I have much to learn about zsh.

# http://zshwiki.org/home/zle/bindkeys

typeset -A key

key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"    ]]  && bindkey  "${key[Home]}"    beginning-of-line
[[ -n "${key[End]}"     ]]  && bindkey  "${key[End]}"     end-of-line
[[ -n "${key[Insert]}"  ]]  && bindkey  "${key[Insert]}"  overwrite-mode
[[ -n "${key[Delete]}"  ]]  && bindkey  "${key[Delete]}"  delete-char
[[ -n "${key[Up]}"      ]]  && bindkey  "${key[Up]}"      history-beginning-search-backward
[[ -n "${key[Down]}"    ]]  && bindkey  "${key[Down]}"    history-beginning-search-forward
[[ -n "${key[Left]}"    ]]  && bindkey  "${key[Left]}"    backward-char
[[ -n "${key[Right]}"   ]]  && bindkey  "${key[Right]}"   forward-char

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
function zle-line-init () {
    echoti smkx
}
function zle-line-finish () {
    echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish

bindkey "\e[A" history-beginning-search-backward
bindkey "\e[B" history-beginning-search-forward

Last edited by graysky (2012-10-01 20:58:21)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB