fix(zsh): improve zsh integration inline mode

This commit is contained in:
alexandre pasmantier 2025-07-10 21:12:33 +02:00
parent 0cdf65a204
commit 83711f6d30
2 changed files with 8 additions and 1 deletions

View File

@ -75,6 +75,12 @@ alias b := build
# Build the project in release mode
br: (build 'release')
# test the zsh shell completion script in debug mode
# Run: `source <(just generate-zsh-completion)` directly in zsh
@generate-zsh-completion:
eval "$(cargo run -- init zsh | sed 's/tv /.\/target\/debug\/tv /')"
# Update the project's changelog
@update-changelog:
echo "Updating changelog..."

View File

@ -30,6 +30,7 @@ __tv_path_completion() {
leftover=${leftover/#\/}
[ -z "$dir" ] && dir='.'
[ "$dir" != "/" ] && dir="${dir/%\//}"
zle -I
matches=$(
shift
tv "$dir" --autocomplete-prompt "$lbuf" --inline --input "$leftover" < /dev/tty | while read -r item; do
@ -94,8 +95,8 @@ _tv_shell_history() {
output=$(history -n -1 0 | tv --input "$current_prompt" --inline $*)
zle reset-prompt
if [[ -n $output ]]; then
zle reset-prompt
RBUFFER=""
LBUFFER=$output