Use pv in numeric mode to stream integer percentages while copying a file, and update a Terminal Widget progress bar in real time. Same idea as the rsync progress recipe, but works for any byte stream where you know the total size.
Requires: pv (brew install pv) and the Terminal Widget CLI.
Setup: Add a Terminal Widget with target copyjob (or pass a custom target as the first script argument).
Usage:
./copy-progress.sh [TARGET] SRC DST
Example:
./copy-progress.sh copyjob ~/Downloads/large-archive.zip ~/Backup/large-archive.zip
The script uses pv -n (percentages on stderr, one integer per line) and terminal-widget --background on each update so the menu bar app is not activated repeatedly. Adjust -i 0.25 in the script to change how often the widget refreshes.
You can adapt the same loop for pipelines, for example tar czf - … | pv -n -s "$BYTES" | ssh host 'tar xzf -'.