Skip to content

Instantly share code, notes, and snippets.

@Wevah
Created May 10, 2021 18:51
Show Gist options
  • Save Wevah/8c4315833cd0aa66c6a8921c0d1912d1 to your computer and use it in GitHub Desktop.
Save Wevah/8c4315833cd0aa66c6a8921c0d1912d1 to your computer and use it in GitHub Desktop.
Paparazzi! download block generator
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "I need a file!"
exit 1
fi
baseName=$(basename "$1")
downloadName="${baseName%.*}"
hash=$(shasum -a 256 "$baseName" | cut -d' ' -f1)
fileSize=$(stat -f%z "$1")
fileSize=$(printf "%'u" "$fileSize")
modDate=$(stat -f%Sm -t"%B %e, %Y" "$1")
datetime=$(stat -f%Sm -t"%Y-%m-%d" "$1")
# echo $fileSize
cat <<EOF
<p class="download">
<a href="downloads/${baseName}">${downloadName}</a> (10.9+; Compressed .dmg) <span class="info">[${fileSize} bytes]<span> <time datetime="${datetime}">${modDate}</time>
<span class="hash">SHA-256: ${hash}</span>
</p>
EOF
@Wevah
Copy link
Author

Wevah commented May 10, 2021

I'm superseding this with a Swift version that will be put in a proper repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment