Skip to content

Instantly share code, notes, and snippets.

@chrstphrchvz
Created June 12, 2018 01:53
Show Gist options
  • Save chrstphrchvz/7f534a72d9616e4384edae8bf1f57ffe to your computer and use it in GitHub Desktop.
Save chrstphrchvz/7f534a72d9616e4384edae8bf1f57ffe to your computer and use it in GitHub Desktop.
Get MacPorts checksums for macOS Finder Services menu (based on https://superuser.com/a/876122/414616)
on run {input, parameters}
with timeout of 360 seconds
tell application "System Events"
activate
display dialog input buttons {"OK"} default button 1 with title "MacPorts checksums" giving up after 300 --seconds
end tell
end timeout
end run
for file; do
if [[ -d "$file" ]]; then
echo "$(basename "$file") is a directory"
else
cd "$(dirname "$file")"
echo -e "$(basename "$file")\r"
echo -e "checksums rmd160 $(/usr/bin/openssl dgst -rmd160 "$(basename "$file")" | egrep -o [a-f0-9]{40}) \\"
echo -e " sha256 $(/usr/bin/openssl dgst -sha256 "$(basename "$file")" | egrep -o [a-f0-9]{64}) \\"
echo -e " size $(stat -f %z "$file")"
fi
done | tr "\n" "\r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment