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

Switched Backspace vs Ctrl+Backspace default behaviour #28

Closed
antis81 opened this issue Oct 12, 2021 · 5 comments
Closed

Switched Backspace vs Ctrl+Backspace default behaviour #28

antis81 opened this issue Oct 12, 2021 · 5 comments

Comments

@antis81
Copy link

antis81 commented Oct 12, 2021

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
Copy link
Contributor

mozzieongit commented Feb 25, 2023

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 🤦

@antis81
Copy link
Author

antis81 commented Jun 23, 2023

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 ☹️):

  • QTerminal defaults to TERM=xterm-256color (prints "branded" Manjaro prompt manjaro_zsh_prompt)
  • XTerm defaults to TERM=xterm (prints ~ > prompt)
  • TTY defaults to TERM=linux (also prints ~ > prompt)

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 🥳). Do you know what "engine" Manjaro sets on TTY? Would be great if we could check on that in the script!

@da2x
Copy link

da2x commented Aug 9, 2023

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
Copy link
Author

antis81 commented Aug 9, 2023

@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.

@antis81
Copy link
Author

antis81 commented Nov 7, 2024

Meanwhile in another galaxy… -> PR to QTerminal

Case closed! 😸

@antis81 antis81 closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants