Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Aug 11, 2023
1 parent abf61af commit 966d5b9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions example/cmd/_test/bash-ble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ _example_completion() {
export COMP_WORDBREAKS
export COMP_LINE

local compline="${COMP_LINE:0:${COMP_POINT}}"
local nospace data compline="${COMP_LINE:0:${COMP_POINT}}"

if echo ${compline}"''" | xargs echo 2>/dev/null > /dev/null; then
data=$(echo ${compline}"''" | xargs example _carapace bash)
elif echo ${compline} | sed "s/\$/'/" | xargs echo 2>/dev/null > /dev/null; then
data=$(echo ${compline} | sed "s/\$/'/" | xargs example _carapace bash)
else
data=$(echo ${compline} | sed 's/$/"/' | xargs example _carapace bash)
fi

IFS=$'\001' read -r -d '' nospace data <<<"${data}"
mapfile -t COMPREPLY < <(echo "${data}")
unset COMPREPLY[-1]

[ "${nospace}" = true ] && compopt -o nospace
local IFS=$'\n'
mapfile -t COMPREPLY < <(echo "$compline" | sed -e "s/ \$/ ''/" -e 's/"/\"/g' | xargs example _carapace bash)
[[ "${COMPREPLY[*]}" == "" ]] && COMPREPLY=() # fix for mapfile creating a non-empty array from empty command output

compopt -o nospace
}


complete -o noquote -F _example_completion example

_example_completion_ble() {
if [[ ${BLE_ATTACHED-} ]]; then
Expand Down

0 comments on commit 966d5b9

Please sign in to comment.