Skip to content

Instantly share code, notes, and snippets.

@boberito
Created April 12, 2021 19:04
Show Gist options
  • Save boberito/d89ea248de6713bd84ed76217549693c to your computer and use it in GitHub Desktop.
Save boberito/d89ea248de6713bd84ed76217549693c to your computer and use it in GitHub Desktop.
Applescript Progress bar from Curl output redirect
#!/bin/bash
osacompile -x -o test.app<<EOF
set progress description to "Download progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1
delay 5
set i to 0
set progress total steps to 100
repeat until i = 100
try
set i to (do shell script "grep -p '.*[0-9].*' /Library/Logs/curlout.stderr | tr -u '\\r' '\\n' | tail -1 | awk '{print \$1}'")
set progress additional description to "Download is " & i & "% complete"
set progress completed steps to i
delay 1
on error thisErr
display alert thisErr
exit repeat
end try
end repeat
EOF
sleep 3
open test.app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment