Updated linux bash completion (#44961)

This commit is contained in:
karnigen
2025-05-09 15:24:52 -04:00
committed by GitHub
parent b12aa38a44
commit 55f4610bc2
+25 -10
View File
@@ -1,17 +1,32 @@
#/usr/bin/env bash
#!/usr/bin/env bash
# set -x
# To install:
# > vcpkg integrate bash
# This adds the following line to ~/.bashrc:
# source ~/vcpkg/scripts/vcpkg_completion.bash
# Details: bash and utilities from bash-completion
# Bash commands: compgen, complete
# Input: COMP_WORDS, COMP_CWORD, COMP_LINE, COMP_POINT, COMP_KEY, COMP_WORDBREAKS
# Output: COMPREPLY
_vcpkg_completions()
{
local vcpkg_executable=${COMP_WORDS[0]}
local remaining_command_line=${COMP_LINE:(${#vcpkg_executable}+1)}
COMPREPLY=($(${vcpkg_executable} autocomplete "${remaining_command_line}" -- 2>/dev/null))
local vcpkg_executable=${COMP_WORDS[0]}
local remaining_command_line=${COMP_LINE:(${#vcpkg_executable}+1)}
# echo "rem:$remaining_command_line"
# Colon is treated as a delimiter in bash. The following workaround
# allows triplet completion to work correctly in the syntax:
# zlib:x64-windows
local cur
_get_comp_words_by_ref -n : cur
__ltrim_colon_completions "$cur"
if [ $COMP_CWORD -eq 1 ]; then
local opts=$(${vcpkg_executable} autocomplete ${remaining_command_line})
else
local opts=$(${vcpkg_executable} autocomplete ${remaining_command_line} --)
fi
#echo "opts:$opts"
COMPREPLY=($(compgen -W "${opts}" -- ${COMP_WORDS[COMP_CWORD]}) )
#echo "COMPREPLY:$COMPREPLY"
}
complete -F _vcpkg_completions vcpkg