How to keep your Mac awake: The CLI Way


Have you ever found yourself in need of keeping your Mac awake during those marathon work sessions? While third-party apps like Caffeine have been popular choices, did you know macOS has its own hidden gem? Enter the “caffeinate” command, a powerful tool right at your fingertips within the macOS ecosystem.

What is Caffeinate?

Hidden within /usr/bin/caffeinate, the caffeinate command is macOS’ native solution to prevent your system from slipping into slumber mode. Think of it as your digital caffeine boost, signaling your Mac to stay vigilant while you handle your tasks.

How Does it Operate?

When activated, caffeinate creates assertions that tweak your system’s sleep tendencies. By default, it wards off idle sleep, but its versatility shines through customizable options:

  • -d: Keeps your display from dozing off.
  • -i: Prevents idle sleep.
  • -m: Ensures your disk remains active.
  • -s: Halts system sleep when plugged in.
  • -u: Acknowledges user activity, maintaining wakefulness with a default 5-second timeout if specifics aren’t provided.

In Action: A Practical Scenario

Imagine you’re knee-deep in a lengthy build process (perhaps still rocking Gulp 👀). Simply fire up caffeinate with -i, like so: caffeinate -i npm run build. Your Mac will dutifully stay awake until your task reaches completion. It’s simplicity at its finest, yet undeniably impactful.

Why Opt for Caffeinate?

By embracing caffeinate, you bid farewell to external apps for Mac vigilance. This built-in marvel empowers you, particularly beneficial for developers or anyone wrestling with extensive tasks on their Mac.

Next time you crave uninterrupted Mac productivity, unleash the power of caffeinate. And remember, stay caffeinated ☕️!