mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-07 12:05:34 +00:00
fix(shell): unite completion naming conventions
This commit is contained in:
parent
000d18b32e
commit
7e85dd64dc
@ -1,15 +1,17 @@
|
||||
function tv_smart_autocomplete() {
|
||||
local prompt_prefix="${READLINE_LINE:0:$READLINE_POINT}"
|
||||
local prompt_suffix="${READLINE_LINE:$READLINE_POINT}"
|
||||
# prefix (lhs of cursor)
|
||||
local current_prompt="${READLINE_LINE:0:$READLINE_POINT}"
|
||||
|
||||
local output=$(tv --autocomplete-prompt "$prompt_prefix" | tr '\n' ' ')
|
||||
local output=$(tv --autocomplete-prompt "$current_prompt" | tr '\n' ' ')
|
||||
|
||||
if [[ -n $output ]]; then
|
||||
# suffix (rhs of cursor)
|
||||
local rhs="${READLINE_LINE:$READLINE_POINT}"
|
||||
# add a space if the prompt does not end with one
|
||||
[[ "${prompt_prefix}" != *" " ]] && prompt_prefix="${prompt_prefix} "
|
||||
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
|
||||
|
||||
local lhs=$prompt_prefix$output
|
||||
READLINE_LINE=$lhs$prompt_suffix
|
||||
local lhs=$current_prompt$output
|
||||
READLINE_LINE=$lhs$rhs
|
||||
READLINE_POINT=${#lhs}
|
||||
fi
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
function tv_smart_autocomplete
|
||||
# prefix (lhs of cursor)
|
||||
set -l current_prompt (commandline -cp)
|
||||
|
||||
set -l output (tv --autocomplete-prompt "$current_prompt")
|
||||
|
@ -2,6 +2,7 @@ _tv_smart_autocomplete() {
|
||||
emulate -L zsh
|
||||
zle -I
|
||||
|
||||
# prefix (lhs of cursor)
|
||||
local current_prompt
|
||||
current_prompt=$LBUFFER
|
||||
|
||||
@ -9,6 +10,7 @@ _tv_smart_autocomplete() {
|
||||
output=$(tv --autocomplete-prompt "$current_prompt" $* | tr '\n' ' ')
|
||||
|
||||
if [[ -n $output ]]; then
|
||||
# suffix (rhs of cursor)
|
||||
local rhs=$RBUFFER
|
||||
# add a space if the prompt does not end with one
|
||||
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
|
||||
|
Loading…
x
Reference in New Issue
Block a user