You are not logged in.

#1 2006-10-17 10:48:24

MartinZ
Member
From: Chiloé, Chile
Registered: 2005-06-10
Posts: 379

Problem with home, end and del keys under zsh

Since i installed zsh i cannot use home, end and del keys anymore. They do strange things. Home/End:

martin@myhost> H                                                              
vim

I guess this is useful to execute lots of commands, but i don't want those keys to make that.
Del:

martin@myhost> PACman

It turns 3 letters into uppercase and then i cannot do anything but presing enter to return functionality in writing.

This hapens only under zsh, in consoles and terminal emulators, for both root and user. This Why don't my Home and End keys work in terminals? doesn't seem to be my problem.

Thanks in advance.[/code]


All your base are belong to us

Offline

#2 2006-10-17 17:24:21

paranoos
Member
From: thornhill.on.ca
Registered: 2004-07-22
Posts: 442

Re: Problem with home, end and del keys under zsh

zsh unfortunately doesn't read /etc/inputrc, which tells the shell what commands sent by the terminal emulator mean.

add the following to your .zshrc, and you should be fine.

# key bindings
bindkey "e[1~" beginning-of-line
bindkey "e[4~" end-of-line
bindkey "e[5~" beginning-of-history
bindkey "e[6~" end-of-history
bindkey "e[3~" delete-char
bindkey "e[2~" quoted-insert
bindkey "e[5C" forward-word
bindkey "eOc" emacs-forward-word
bindkey "e[5D" backward-word
bindkey "eOd" emacs-backward-word
bindkey "ee[C" forward-word
bindkey "ee[D" backward-word
bindkey "^H" backward-delete-word
# for rxvt
bindkey "e[8~" end-of-line
bindkey "e[7~" beginning-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
bindkey "eOH" beginning-of-line
bindkey "eOF" end-of-line
# for freebsd console
bindkey "e[H" beginning-of-line
bindkey "e[F" end-of-line
# completion in the middle of a line
bindkey '^i' expand-or-complete-prefix

by the way, i've changed some of the keys. for instance, ctrl-left and ctrl-right move back and forward by whole words. default is alt i believe.

Offline

#3 2006-10-17 17:28:27

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Problem with home, end and del keys under zsh

Does inputrc not work for zsh?

Offline

#4 2006-10-17 17:59:45

paranoos
Member
From: thornhill.on.ca
Registered: 2004-07-22
Posts: 442

Re: Problem with home, end and del keys under zsh

phrakture wrote:

Does inputrc not work for zsh?

riiight, it's inputrc that doesn't work with zsh, not termcap. i got confused. corrected my post. thanks phrakture

Offline

#5 2006-10-17 18:46:24

MartinZ
Member
From: Chiloé, Chile
Registered: 2005-06-10
Posts: 379

Re: Problem with home, end and del keys under zsh

Thanks a lot!!! big_smile big_smile big_smile

I guess this should be on the zsh-wiki, I'll add it.


All your base are belong to us

Offline

#6 2006-10-17 19:46:07

Leffe
Member
Registered: 2006-05-30
Posts: 47

Re: Problem with home, end and del keys under zsh

I prefer this solution, as it will adapt to whatever setup you are currently using:

autoload zkbd
[[ ! -f ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE ]] && zkbd
source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE

[[ -n ${key[Backspace]} ]] && bindkey "${key[Backspace]}" backward-delete-char
[[ -n ${key[Insert]} ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[PageUp]} ]] && bindkey "${key[PageUp]}" up-line-or-history
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[PageDown]} ]] && bindkey "${key[PageDown]}" down-line-or-history
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char

Offline

#7 2008-10-04 00:59:13

rine
Member
From: Germany
Registered: 2008-03-04
Posts: 217

Re: Problem with home, end and del keys under zsh

Well I now have a problem with this. The keys worked a few hours ago. Now they don't. I commented everything in my .zshrc but the keybindings but they still didn't work. I haven't really done anything other than creating ~/.zprofile with this content (or at least I can't remember):

if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/vc/1 ]]; then
  startx
  logout
fi

The stuff under "reading $terminfo[]" from http://zshwiki.org/home/zle/bindkeys works, but it's extremly slow. It takes about a second for the cursor to move to the front when pressing home.

This is my .zshrc so far http://pastebin.com/m66ede710

Offline

#8 2009-03-31 10:38:18

cwjiof
Member
From: Taichung, TW
Registered: 2008-01-27
Posts: 131

Re: Problem with home, end and del keys under zsh

The code of key bindings in the 2nd post may have missed "\" before the letter "e", or it won't function on my roxterm. For example:

bindkey "\e[3~" delete-char

Last edited by cwjiof (2009-03-31 10:38:50)

Offline

#9 2011-11-11 10:53:56

bop
Member
Registered: 2011-11-11
Posts: 1

Re: Problem with home, end and del keys under zsh

cwjiof wrote:

The code of key bindings in the 2nd post may have missed "\" before the letter "e", or it won't function on my roxterm. For example:

bindkey "\e[3~" delete-char

I had the same problem (years ago, it seems). That solution perfectly solve it.

bop

Offline

#10 2011-11-11 12:57:10

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Problem with home, end and del keys under zsh

Hi bop, welcome to the forums. However, the thread you posted in is far more than two years old so not many will appreciate your experience any more.

Please read our forum etiquette esp. the section about necro bumping.

Closing.


To know or not to know ...
... the questions remain forever.

Offline

Board footer

Powered by FluxBB