mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-08 04:25:23 +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() {
|
function tv_smart_autocomplete() {
|
||||||
local prompt_prefix="${READLINE_LINE:0:$READLINE_POINT}"
|
# prefix (lhs of cursor)
|
||||||
local prompt_suffix="${READLINE_LINE:$READLINE_POINT}"
|
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
|
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
|
# 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
|
local lhs=$current_prompt$output
|
||||||
READLINE_LINE=$lhs$prompt_suffix
|
READLINE_LINE=$lhs$rhs
|
||||||
READLINE_POINT=${#lhs}
|
READLINE_POINT=${#lhs}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
function tv_smart_autocomplete
|
function tv_smart_autocomplete
|
||||||
|
# prefix (lhs of cursor)
|
||||||
set -l current_prompt (commandline -cp)
|
set -l current_prompt (commandline -cp)
|
||||||
|
|
||||||
set -l output (tv --autocomplete-prompt "$current_prompt")
|
set -l output (tv --autocomplete-prompt "$current_prompt")
|
||||||
|
@ -2,6 +2,7 @@ _tv_smart_autocomplete() {
|
|||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
zle -I
|
zle -I
|
||||||
|
|
||||||
|
# prefix (lhs of cursor)
|
||||||
local current_prompt
|
local current_prompt
|
||||||
current_prompt=$LBUFFER
|
current_prompt=$LBUFFER
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ _tv_smart_autocomplete() {
|
|||||||
output=$(tv --autocomplete-prompt "$current_prompt" $* | tr '\n' ' ')
|
output=$(tv --autocomplete-prompt "$current_prompt" $* | tr '\n' ' ')
|
||||||
|
|
||||||
if [[ -n $output ]]; then
|
if [[ -n $output ]]; then
|
||||||
|
# suffix (rhs of cursor)
|
||||||
local rhs=$RBUFFER
|
local rhs=$RBUFFER
|
||||||
# add a space if the prompt does not end with one
|
# add a space if the prompt does not end with one
|
||||||
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
|
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user