How to prevent macOS Sequoia from sleeping via command line

macOS Sequoia suspends background terminal tasks when idle or when the screen turns off. Here's how to keep scripts running using caffeinate.