You are not logged in.

#1 2020-06-22 00:39:21

davidstein
Member
Registered: 2020-06-22
Posts: 31

[SOLVED] urxvt Control-Arrow forward word error

I am using zsh with urxvt. I added the following to my .zshrc
```
key[Control-Left]="${terminfo[kLFT5]}"
key[Control-Right]="${terminfo[kRIT5]}"

[[ -n "${key[Control-Left]}"  ]] && bindkey -- "${key[Control-Left]}"  backward-word
[[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word
```
as per the wiki https://wiki.archlinux.org/index.php/zsh#Key_bindings.

When I try to use Control-Arrow to move words, the words are duplicated and printed to the terminal.
Has anyone had success using Control-Arrow to jump words with zsh and urxvt?

Last edited by davidstein (2020-06-22 16:19:23)

Offline

#2 2020-06-22 01:01:16

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] urxvt Control-Arrow forward word error

Sounds like your prompt is broken. Paste your .zshrc and the output of "echo $TERM".


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2020-06-22 01:17:17

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

echo $TERM

rxvt-unicode-256color
cat .zshrc

# Lines configured by zsh-newuser-install
HISTFILE=~/.config/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt extendedglob
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/david/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

XDG_CONFIG_HOME=~/.config

# Autocomplete aliases
setopt COMPLETE_ALIASES

typeset -g -A key

key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Backspace]="${terminfo[kbs]}"
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]}"
key[Shift-Tab]="${terminfo[kcbt]}"

# Cursor movement 
key[Control-Left]="${terminfo[kLFT5]}"
key[Control-Right]="${terminfo[kRIT5]}"

[[ -n "${key[Control-Left]}"  ]] && bindkey -- "${key[Control-Left]}"  backward-word
[[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word

# Aliases
alias update="source ~/.config/.zshrc"
alias config="vim ~/.config/.zshrc"

Thanks!

Last edited by davidstein (2020-06-22 01:28:11)

Offline

#4 2020-06-22 01:45:50

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] urxvt Control-Arrow forward word error

The prompt looks fine. Reading the wiki page, it looks like you are missing a block that is necessary for all those terminfo assignments:

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2020-06-22 01:56:36

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

Ahh I missed that. I added it in but still same issue. Its weird, the ${terminfo} variables seem to be empty when I echo them in the shell

Offline

#6 2020-06-22 06:41:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,776

Re: [SOLVED] urxvt Control-Arrow forward word error

I tend to just bind the escape codes…

bindkey "\e[1;5D" backward-word
bindkey "\e[1;5C" forward-word

Offline

#7 2020-06-22 13:09:29

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

I tried that but I still get the same issue

Offline

#8 2020-06-22 13:13:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,776

Re: [SOLVED] urxvt Control-Arrow forward word error

Output of "bindkey"?

Offline

#9 2020-06-22 13:33:44

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

No output when I run it

Offline

#10 2020-06-22 13:36:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,776

Re: [SOLVED] urxvt Control-Arrow forward word error

Something's off here - what if you run those command inside the shell?

Offline

#11 2020-06-22 13:41:33

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

Ahh sorry I messe up, this is the bindkey output

bindkey
"^A"-"^C" self-insert
"^D" list-choices
"^E"-"^F" self-insert
"^G" list-expand
"^H" vi-backward-delete-char
"^I" expand-or-complete
"^J" accept-line
"^K" self-insert
"^L" clear-screen
"^M" accept-line
"^N"-"^P" self-insert
"^Q" vi-quoted-insert
"^R" redisplay
"^S"-"^T" self-insert
"^U" vi-kill-line
"^V" vi-quoted-insert
"^W" vi-backward-kill-word
"^X^R" _read_comp
"^X?" _complete_debug
"^XC" _correct_filename
"^Xa" _expand_alias
"^Xc" _correct_word
"^Xd" _list_expansions
"^Xe" _expand_word
"^Xh" _complete_help
"^Xm" _most_recent_file
"^Xn" _next_tags
"^Xt" _complete_tag
"^X~" _bash_list-choices
"^Y"-"^Z" self-insert
"^[" vi-cmd-mode
"^[," _history-complete-newer
"^[/" _history-complete-older
"^[OA" up-line-or-history
"^[OB" down-line-or-history
"^[OC" vi-forward-char
"^[OD" vi-backward-char
"^[[1;5C" forward-word
"^[[1;5D" backward-word
"^[[200~" bracketed-paste
"^[[A" up-line-or-history
"^[[B" down-line-or-history
"^[[C" vi-forward-char
"^[[D" vi-backward-char
"^[~" _bash_complete-word
"^\\\\"-"~" self-insert
"^?" vi-backward-delete-char
"\M-^@"-"\M-^?" self-insert

Offline

#12 2020-06-22 13:53:09

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,776

Re: [SOLVED] urxvt Control-Arrow forward word error

If you run "cat" and then enter ctrl+left and ctrl+right, what's the output?

Offline

#13 2020-06-22 14:09:48

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

ctrl+right = ^[Oc
ctrl+left = ^[Od

Same problem if I bind those

Offline

#14 2020-06-22 14:52:06

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,776

Re: [SOLVED] urxvt Control-Arrow forward word error

Try to run "zsh -f" (this will skip your zshrc) and try

% bindkey "\e[OD" backward-word
% bindkey "\e[OC" forward-word
# test here, if fails
% bindkey "\eOD" backward-word
% bindkey "\eOC" forward-word
# test here

and see whether one works there, then try to incoporate it in your zshrc

Offline

#15 2020-06-22 15:43:36

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

Well that at least stops the annoying word duplication, but now nothing happens when I control-Arrow. Maybe I'll keep trying things with zsh -f

Offline

#16 2020-06-22 15:52:48

davidstein
Member
Registered: 2020-06-22
Posts: 31

Re: [SOLVED] urxvt Control-Arrow forward word error

Ok after zsh -f and opening a new shell,

bindkey "\e^[Od" backward-word
bindkey "\e^[Oc" forward-word

are working.

Thanks for the help

How do I mark as solved?

Last edited by davidstein (2020-06-22 16:03:54)

Offline

#17 2020-06-22 16:15:10

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED] urxvt Control-Arrow forward word error

davidstein wrote:

How do I mark as solved?

https://wiki.archlinux.org/index.php/Co … ow_to_post

How to post wrote:

Finally, when a solution is found, mark your thread as solved by editing the first post and prepending the tag [SOLVED] to the title in the "Subject" field.

Offline

Board footer

Powered by FluxBB