From 92b9d417fb70d576e7c4aa9534321e591c88f0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=BCchler?= Date: Sun, 10 Aug 2025 01:37:32 +0200 Subject: [PATCH] fix(zsh): apply keybindings reliably on first startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - set bindkey -e before custom binds and load zsh/terminfo early - remove later bindkey -e that reset earlier keymaps - preserve terminfo application mode hooks This prevents Ctrl+Arrow and other navigation keys from failing until .zshrc is re-sourced. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode --- .zshrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.zshrc b/.zshrc index 668b7e2..488958f 100644 --- a/.zshrc +++ b/.zshrc @@ -139,6 +139,12 @@ alias ...="cd ../.." # Robust keybinds for navigation and editing (support most terminals) # ===================== +# Ensure Emacs keymap is set before custom bindings so later changes don't reset them +bindkey -e + +# Load terminfo module for $terminfo[] and echoti +zmodload zsh/terminfo 2>/dev/null || true + # VSCode terminal compatibility detection export IS_VSCODE_TERM=0 if [[ "$TERM_PROGRAM" == "vscode" ]] || [[ -n "$VSCODE_IPC_HOOK_CLI" ]]; then @@ -256,10 +262,8 @@ autoload -Uz compinit && compinit # Keybinds (Navigation, Editing, FZF, Completion) # ===================== -# Emacs mode by default (comment out for vi mode) -bindkey -e -# Uncomment below for vi mode -# bindkey -v +# Emacs/vi mode selection handled earlier to avoid resetting custom binds +# bindkey -v # Uncomment to use vi mode instead # History search bindkey '^R' fzf-history-widget # fzf history search (fzf-tab)