Chrysostomus / manjaro-zsh-config

Zsh configuration package for manjaro
MIT License
127 stars 52 forks source link

Switched Backspace vs Ctrl+Backspace default behaviour #28

Open antis81 opened 3 years ago

antis81 commented 3 years ago

Probably it's just me, but I am used to deleting a single character using the Backspace key and a Word using Ctrl+Backspace. In version 0.20-3 the default behaviour is exactly switched. I worked around that:

# Use powerline
USE_POWERLINE="true"
# Source mnajaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
  source /usr/share/zsh/manjaro-zsh-prompt
fi

# Nils Fenner's key bindings
bindkey '^H' backward-delete-char          # Backspace         -> delete last char
bindkey '^?' backward-kill-word            # Ctrl+Backspace    -> delete last word
mozzieongit commented 1 year ago

That seems weird. AFAIK your bindkey should be doing the opposite. My terminal uses ^H for ctrl+backspace and ^? for backspace.

To what version number are you referring? nvm, package version :facepalm:

antis81 commented 1 year ago

To be fair the description is not complete and - as always - takes a specific situation. For me this is QTerminal (:heart:).

Compared to "native" tty (e.g. Ctrl+Alt+F2) the story is completely different (:partying_face:): Commenting my customized bindkey … lines results in Backspace working (del. single char) while Ctrl+Backspace will do nothing at all.

Okay… just compared my env's. The only tty related variables are TERM and XDG_SESSION_TYPE.

As you might already know setting the TERM variable results in a different prompt (no effect on keybindings though :frowning_face:):

Setting XDG_SESSION_TYPE (tty vs x11) does not have a notable effect on bindings either -> skip it…

Now QTerminal can also set the "emulation behavior" (not sure what "default" means here). Setting this to linux the issue becomes reproducable (yay :partying_face:). Do you know what "engine" Manjaro sets on TTY? Would be great if we could check on that in the script!

da2x commented 1 year ago

I have the same problem with an out-of-the-box Norwegian keyboard layout. My terminals use ^? for Ctrl+BackSpace and ^H for BackSpace. It’s the same in Fedora and Ubuntu, for what it’s worth.

antis81 commented 1 year ago

@da2x Thanks for mentioning.

Like I tried to outline in my previous comment above this depends on the tty emulation in use. The key-binding is set here.

To make this generic we are searching for some reliable condition that works ideally on all systems. Something like

if [[ … ]]; then
  bindkey '^H' backward-delete-char                               # Backspace         -> delete last char
  bindkey '^?' backward-kill-word                                 # Ctrl+Backspace    -> delete last word
else
  bindkey '^H' backward-kill-word                                 # delete previous word with ctrl+backspace
fi

QTerminal (and other terminal emulators) can switch the TTY emulation. May be useful for trying things out manually.

manjaro-zsh-config-switched-bindkey

However I don't know directly how the aliases default,macbook,linux,… map there.