Skip to content

Instantly share code, notes, and snippets.

@ahmetb
Created November 7, 2019 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmetb/9d0fd384adfdaf816036d6f687798bb5 to your computer and use it in GitHub Desktop.
Save ahmetb/9d0fd384adfdaf816036d6f687798bb5 to your computer and use it in GitHub Desktop.
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