From af8f3c814bf1bf67ce16051bc4e525665136a47e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 15 Mar 2023 17:24:33 +0000 Subject: [PATCH] home: zsh: ensure application mode with zle --- home/zsh/extra-mappings.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/home/zsh/extra-mappings.zsh b/home/zsh/extra-mappings.zsh index aa7fb54..c8682cc 100644 --- a/home/zsh/extra-mappings.zsh +++ b/home/zsh/extra-mappings.zsh @@ -15,6 +15,19 @@ if ! { [ "$TERM" != emacs ] && (( ${+terminfo} )) 2>/dev/null; }; then return fi +# Make sure that the terminal is in application mode when zle is active, since +# only then values from $terminfo are valid +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + autoload -Uz add-zle-hook-widget + + zle_application_mode_start() { echoti smkx; } + 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 + + # Fix delete key not working if [ -n "${terminfo[kdch1]}" ]; then bindkey -M emacs "${terminfo[kdch1]}" delete-char