diff --git a/crates/television-utils/shell/completion.bash b/crates/television-utils/shell/completion.bash index ef0281f..e570403 100644 --- a/crates/television-utils/shell/completion.bash +++ b/crates/television-utils/shell/completion.bash @@ -4,6 +4,9 @@ function tv_smart_autocomplete() { local output=$(tv --autocomplete-prompt "$current_prompt") if [[ -n $output ]]; then + # add a space if the prompt does not end with one + [[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} " + READLINE_LINE=$current_prompt$output READLINE_POINT=${#READLINE_LINE} fi diff --git a/crates/television-utils/shell/completion.fish b/crates/television-utils/shell/completion.fish index 222c727..6e84ebe 100644 --- a/crates/television-utils/shell/completion.fish +++ b/crates/television-utils/shell/completion.fish @@ -4,6 +4,8 @@ function tv_smart_autocomplete set -l output (tv --autocomplete-prompt "$current_prompt") if test -n "$output" + # add a space if the prompt does not end with one + string match -q "* " -- "$current_prompt" || set current_prompt "$current_prompt " commandline -r "$current_prompt$output" end end diff --git a/crates/television-utils/shell/completion.zsh b/crates/television-utils/shell/completion.zsh index 3aff40b..2624e44 100644 --- a/crates/television-utils/shell/completion.zsh +++ b/crates/television-utils/shell/completion.zsh @@ -13,6 +13,8 @@ _tv_smart_autocomplete() { if [[ -n $output ]]; then zle reset-prompt RBUFFER="" + # add a space if the prompt does not end with one + [[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} " LBUFFER=$current_prompt$output # uncomment this to automatically accept the line