Keeps the Mac awake as long as the terminal window stays open — and shows, big and clear, that this window is keeping the machine awake and since when. That makes it easy to spot the "blocking" window at any time.
The script starts caffeinate -i (prevents idle sleep) and ties it to the
lifetime of the script via -w "$$". As soon as the script ends — by Ctrl+C
or closing the window — the Mac is allowed to sleep again.
The window displays a large ASCII banner along with the elapsed time since start.
./keep-alive.shTo stop: Ctrl+C or close the window.
- macOS (uses the built-in
caffeinate) - bash