Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
list all files in archives hosted in a krew-index (run from repo root)
#!/bin/bash
set -euo pipefail
files=$( grep -hRE '\.(tar\.gz|zip)' plugins/* | \
sed -E 's/^\s+(-\ )?uri:\s//g' | \
sed -E 's/"//g' | \
sort | \
uniq )
for f in $files; do
if [[ "$f" = *.tar.gz ]]; then
curl -sSLf "$f" | tar tzvf -
echo
elif [[ "$f" = *.zip ]]; then
tmp="$(mktemp).zip"
curl -sSLf "$f" > "$tmp"
trap 'rm -- "$tmp"' EXIT
unzip -Z1 "$tmp"
else
echo "UNKNOWN ARCHIVE: $f" >&2
fi
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.