From 3856f1ddb76a494c389b7f3fc8a991e02f5c74f3 Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Fri, 15 Nov 2024 16:33:14 +0100 Subject: [PATCH] Update bash-completion --- bash-completion/completions/ue-lite | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/bash-completion/completions/ue-lite b/bash-completion/completions/ue-lite index f0f6241..8c81636 100644 --- a/bash-completion/completions/ue-lite +++ b/bash-completion/completions/ue-lite @@ -1,18 +1,32 @@ -#! /bin/bash +#!/usr/bin/env bash : ${PROG:=$(basename ${BASH_SOURCE})} +# Macs have bash3 for which the bash-completion package doesn't include +# _init_completion. This is a minimal version of that function. +_cli_init_completion() { + COMPREPLY=() + _get_comp_words_by_ref "$@" cur prev words cword +} + _cli_bash_autocomplete() { if [[ "${COMP_WORDS[0]}" != "source" ]]; then - local cur opts base + local cur opts base words COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" + if declare -F _init_completion >/dev/null 2>&1; then + _init_completion -n "=:" || return + else + _cli_init_completion -n "=:" || return + fi + words=("${words[@]:0:$cword}") if [[ "$cur" == "-"* ]]; then - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) + requestComp="${words[*]} ${cur} --generate-shell-completion" else - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) + requestComp="${words[*]} --generate-shell-completion" fi - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + opts=$(eval "${requestComp}" 2>/dev/null) + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi }