From bc5fa3f6796b0ab43dd408ac921279afce3c503c Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 15 Mar 2023 17:15:57 +0000 Subject: [PATCH] home: zsh: use terminfo for mappings --- home/zsh/extra-mappings.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/home/zsh/extra-mappings.zsh b/home/zsh/extra-mappings.zsh index 8c0d886..2158250 100644 --- a/home/zsh/extra-mappings.zsh +++ b/home/zsh/extra-mappings.zsh @@ -1,5 +1,13 @@ -# Fix delete key not working -bindkey "\e[3~" delete-char +# shellcheck disable=2154 + +# The expression: (( ${+terminfo} )) should never fail, but does if we +# don't have a tty, perhaps due to a bug in the zsh/terminfo module. +if [[ "$TERM" != emacs ]] && (( ${+terminfo} )) 2>/dev/null; then + # Fix delete key not working + ((${+terminfo[kdch1]})) && bindkey -- "${terminfo[kdch1]}" delete-char + # Enable Shift-Tab to go backwards in completion list + ((${+terminfo[kcbt]})) && bindkey -- "${terminfo[kcbt]}" reverse-menu-complete +fi # Fix Ctrl+u killing from the cursor instead of the whole line bindkey '^u' backward-kill-line