From a97f239292df267c5131e0b5e614fa6a6542794a Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 30 Jun 2026 01:46:13 +0530 Subject: [PATCH] Bash: avoid blanking the prompt when cancelling interactive completions --- CHANGELOG.md | 1 + templates/bash.txt | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b9b30..63d6ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PowerShell: use fully qualified names when invoking cmdlets. - Bash/Fish/POSIX/Zsh: resolve symlinks on Windows. - Zsh: avoid inserting a trailing space when cancelling interactive Space-Tab completions. +- Bash: redraw the prompt instead of blanking it when cancelling interactive Space-Tab completions. ## [0.9.9] - 2026-01-31 diff --git a/templates/bash.txt b/templates/bash.txt index 1888fe3..7a64fad 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -178,7 +178,7 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER # If there is a space after the last word, use interactive selection. elif [[ -z ${COMP_WORDS[-1]} ]]; then # shellcheck disable=SC2312 - __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && { + if __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")"; then # In case the terminal does not respond to \e[5n or another # mechanism steals the response, it is still worth completing # the directory in the command line. @@ -189,7 +189,12 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER # builtin "bind". bind -x '"\e[0n": __zoxide_z_complete_helper' \builtin printf '\e[5n' >/dev/tty - } + else + # The interactive selection was cancelled. fzf has drawn over + # the prompt, so redraw the current line. + bind '"\e[0n": redraw-current-line' + \builtin printf '\e[5n' >/dev/tty + fi fi }