From 789ef717718400af83e29de177758a0d22c283ab Mon Sep 17 00:00:00 2001 From: Andrejus Date: Fri, 27 Mar 2026 16:21:58 +0000 Subject: [PATCH] fix(zsh): Tab completion and colby buffer expansion Fix fzf_default_completion stale pointer after zle -D by setting it to expand-or-complete before deleting the lazy comp widget. Rebind ^I explicitly after widget deletion and add safety net in widgets.zsh after bindkey -e. Replace colby() function with ^M buffer expansion so the full copilot --allow-all-tools --allow-all-paths invocation is visible in terminal history and screen recordings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- home/.aliases | 1 - home/.zsh/widgets.zsh | 17 +++++++++++++++++ home/.zshrc | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/home/.aliases b/home/.aliases index 9681326..a3016ee 100644 --- a/home/.aliases +++ b/home/.aliases @@ -51,7 +51,6 @@ _copilot_tmux_wrap() { trap - EXIT INT TERM [[ -n "$TMUX" ]] && (tmux set automatic-rename on &) } -colby() { _copilot_tmux_wrap gh copilot --allow-all-tools --allow-all-paths "$@"; } alias gs='git s' alias gd='git d' alias gdc='git dc' diff --git a/home/.zsh/widgets.zsh b/home/.zsh/widgets.zsh index 3b579c7..1854d35 100644 --- a/home/.zsh/widgets.zsh +++ b/home/.zsh/widgets.zsh @@ -387,5 +387,22 @@ for line in sys.stdin: } zle -N _dots_stash_widget bindkey '^Y' _dots_stash_widget + + # Restore Tab after bindkey -e + if (( ${+widgets[fzf-completion]} )); then + bindkey '^I' fzf-completion + elif (( ${+widgets[_dots_lazy_comp_widget]} )); then + bindkey '^I' _dots_lazy_comp_widget + fi + + # Enter: expand colby → full copilot invocation (visible in terminal history) + _dots_enter_handler() { + if [[ "$BUFFER" == "colby" || "$BUFFER" == "colby "* ]]; then + BUFFER="${BUFFER/#colby/copilot --allow-all-tools --allow-all-paths}" + fi + zle accept-line + } + zle -N _dots_enter_handler + bindkey '^M' _dots_enter_handler } _dots_load_keybindings diff --git a/home/.zshrc b/home/.zshrc index bd51af9..35b4265 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -88,11 +88,14 @@ _dots_init_completion() { # Stub that loads real completion on first Tab, then replays the keypress _dots_lazy_comp_widget() { _dots_init_completion + # Point fzf fallback to real completion before removing this widget + fzf_default_completion=expand-or-complete zle -D _dots_lazy_comp_widget - # If fzf-completion exists (loaded via zle-line-init), use it; otherwise default if (( ${+widgets[fzf-completion]} )); then + bindkey '^I' fzf-completion zle fzf-completion "$@" else + bindkey '^I' expand-or-complete zle expand-or-complete "$@" fi }