Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key binding are not working for zsh #1097

Open
jakbin opened this issue Jan 18, 2024 · 4 comments
Open

key binding are not working for zsh #1097

jakbin opened this issue Jan 18, 2024 · 4 comments

Comments

@jakbin
Copy link

jakbin commented Jan 18, 2024

Expected Behavior

key binding are not working for zsh and bash. like arrow keys and other key bindings.

Here is my full .zshrc file : https://github.com/jakbin/myzsh/blob/main/.zshrc

key_error1

Current Behavior

key binding are not working .

Possible Solution

i thinks works fine before version 1.3.0. It should work like hyper terminal.

Steps to Reproduce (for bugs)
  1. I just open python console .
  2. then try arrow keys. but it is not working.
Context

i simple key bindings are not working , it affect my working.

System Information
@yan12125
Copy link
Member

If you choose "default" in Preferences -> Behavior -> Emulation, something is not set correctly on the system. terminfo/ncurses and global bashrc/zshrc may be worth a look. I have no experience of using terminals on Debian or Kali, so I don't have a concrete idea about what's the issue.

@Bluey26
Copy link

Bluey26 commented Feb 24, 2024

Hello, i cannot reproduce this in archlinux QTerminal 1.4.0.
Key bindings work properly in here, under zsh.

In the python mode, everything seems to work properly (except maybe custom key bindings, but thats seems to be the normal behavior).

@jakbin
Copy link
Author

jakbin commented Feb 24, 2024

@Bluey26 please can you provide that zshrc file ?? So I can test that.

@Bluey26
Copy link

Bluey26 commented Feb 24, 2024

Yes, of course @jakbin

Here goes the relevant lines i use in my .zshrc to navigate:

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
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]}"

# 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[Backspace]}" ]] && bindkey -- "${key[Backspace]}"  backward-delete-char
[[ -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
[[ -n "${key[PageUp]}"    ]] && bindkey -- "${key[PageUp]}"     beginning-of-buffer-or-history
[[ -n "${key[PageDown]}"  ]] && bindkey -- "${key[PageDown]}"   end-of-buffer-or-history
[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}"  reverse-menu-complete

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
	autoload -Uz add-zle-hook-widget
	function zle_application_mode_start { echoti smkx }
	function zle_application_mode_stop { echoti rmkx }
	add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
	add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi

#This part is used for bash-like history search
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search

[[ -n "${key[Up]}"   ]] && bindkey -- "${key[Up]}"   up-line-or-beginning-search
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search

#Here is also backward and forward words:
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word

All this configs were taken from: https://wiki.archlinux.org/title/Zsh#Key_bindings

My zsh version is 5.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants