1

my current keys config is:

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]}"      up-line-or-history
[[ -n "${key[Down]}"    ]]  && bindkey  "${key[Down]}"    down-line-or-history
[[ -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
}

if [ -n "${DISPLAY:-}" ]; then
   zle -N zle-line-init
   zle -N zle-line-finish
fi

completion and other zsh files here: https://github.com/Cynede/dotfiles/blob/master/.zsh/config.sh

The trouble is that this bindkey "${key[Home]}" beginning-of-line doesn't work for terminal with no Xorg running seems like. It pastes ~ on both HOME and END. How can I make it to work without Xorg too?

  • What do you see when you type Ctrl-V, Home? See also this discussion – Stéphane Chazelas Jan 29 '13 at 7:36
  • what I see is ^[[1~ – cnd Jan 29 '13 at 7:51
  • What about print -r -- ${(V)terminfo[khome]}? – Stéphane Chazelas Jan 29 '13 at 10:07
  • what I see is ^[OH – cnd Jan 29 '13 at 10:45
1

The $terminfo special parameter in zsh is filled from data that comes from the terminfo database on your system.

In your case, it seems that the entry in the database for the terminal you're using is incorrect.

The terminfo database is indexed on the value of the $TERM environment variable.

So either $TERM is incorrect or the database is incorrect.

What terminal is that? Is that the console of some BSD operating system? What does $TERM contain? Are you logged in locally or logging in to some remote system (which may have a different terminfo database) over ssh/rsh?

  • True, I were setting wrong TERM right in zsh. Thank you. – cnd Jan 29 '13 at 11:22
  • @Heather. OK. I realise I read the comments backward and would now bet that you're on the Linux console and had TERM set to xterm. Note that you should not set $TERM, it should be set by automatically by the terminal emulator or getty (and transfered automatically via ssh/rlogin/rsh). The only time when you might need to change it is if you're rlogging-in to a system that has different settings for a given entry. – Stéphane Chazelas Jan 29 '13 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.