← Doki

How to keep your Mac awake: caffeinate, apps and settings

By , maker of Doki · Published 29 November 2026

Your Mac dims, then sleeps, when you haven't touched it for a while. That's annoying during a long download, a build, a presentation, or while Claude Code works through a task. Here are four ways to keep it awake, from a one-line command to a menu bar app, and when each one fits.

The short answer

Open Terminal and run caffeinate -d. Your Mac and its screen stay awake until you press Control-C. For a switch you can click instead, use a free menu bar app such as Amphetamine or KeepingYouAwake. None of these keep a MacBook awake with the lid closed on their own.

The four ways, side by side

WayHow you turn it onTimers and rulesCostBest for
1. caffeinateA Terminal commandYes, with flagsFree, built inOne task, or scripts
2. macOS settingsSystem SettingsNoFree, built inA Mac that should never sleep
3. AmphetamineMenu bar appYes, manyFreeFine control and triggers
4. KeepingYouAwakeMenu bar appSimple durationsFree, open sourceA lightweight on/off switch

1. The caffeinate command (built in)

Every Mac has caffeinate. Open Terminal (press ⌘ Space, type Terminal) and run one of these:

It keeps going until you press Control-C or close the Terminal window. Nothing to install, but you have to remember it's running.

2. macOS settings

If a Mac should never sleep, for example one that runs jobs while plugged in:

These stay on until you change them back, so they're better for a Mac on a desk than for a laptop you carry around.

3. Amphetamine

Amphetamine is a free menu bar app from the Mac App Store and the most capable option. You can keep the Mac awake indefinitely, for a set time, until a set time, or while a particular app is running or a file is downloading. It also has an optional closed-display mode for MacBooks, which needs an extra script and your admin password.

4. KeepingYouAwake

KeepingYouAwake is a small, free, open-source menu bar app. Click its cup to keep the Mac awake, click again to let it sleep, or pick a duration. It's a friendly switch for caffeinate. Install it from its site or with brew install --cask keepingyouawake.

Which one should you use?

Questions

How do I keep my Mac awake without an app?

Run caffeinate -d in Terminal. Use caffeinate -i to keep the Mac running but let the screen turn off.

Can I keep a MacBook awake with the lid closed?

Not with caffeinate or most keep-awake apps on their own. A MacBook stays awake with the lid closed when it's plugged in and connected to an external display, keyboard and mouse. Amphetamine's closed-display mode is the other route.

Is it bad to keep my Mac awake all the time?

It uses more power and battery, and a screen left on shows the same image for hours. Keep it awake for as long as a task needs, then let it sleep.

Does keeping the Mac awake help Claude Code?

Yes, for long tasks. If your Mac sleeps, a running Claude Code session pauses until you wake it. Keep the Mac awake, and set up a notification for when Claude Code finishes so you know when to come back.