Use a Terminal command to stop your Mac from sleeping

TekRevue:

We generally want our Macs to sleep when not in use: saving battery life, reducing energy usage, and increasing the longevity of our Mac’s components. But sometimes we intentionally don’t want our Macs to sleep, such as when preparing to give a Keynote presentation or when you’re letting a colleague or family member use your Mac.

In these instances, you could go to System Preferences > Energy Saver and use the slider to tell your Mac to “never” sleep. But this isn’t ideal, as it both involves a few extra steps and you may forget to set it back when you’re done.

Instead, there’s a built-in terminal command that can temporarily keep your Mac awake and prevent all sleep settings. This command is appropriately called caffeinate.

This is a really clever little hack. I give presentations on my Macbook Pro all the time and I’m constantly swiping the trackpad to prevent the machine from going to sleep (even when I don’t have to). You need to remember that you’ve invoked it. The easiest thing to do would be to leave the Terminal open during your presentation. That would remind you to undo the hack after your presentation is over.