.dotfiles/.local/share/bash-completion/completions/ddev
2024-10-22 17:00:36 +07:00

15 lines
424 B
Plaintext

function _ddev() {
# limited to 100 images
for i in {1..5}; do
URL="https://hub.docker.com/v2/repositories/library/?page=$i&page_size=100"
mapfile -t res < <(compgen -W \
"$(curl -sfL "$URL" | jq -r '.results[].name')" \
-- "${COMP_WORDS[1]}")
if [ -z "${res[0]}" ]; then
break
fi
COMPREPLY+=("${res[@]}")
done
}
complete -F _ddev ddev