Keep your Mac awake from the command line with the keepresso CLI
Keepresso ships a small command-line tool so you can control it from the terminal, a shell script, a Makefile, or a CI job, without reaching for the menu bar. The command is keepresso, and it works two ways: it can talk to the menu-bar app, or it can hold the Mac awake on its own like the built-in caffeinate.
Install the command
If you installed Keepresso with Homebrew, the keepresso command is already on your PATH, nothing to do:
brew install --cask gyorgysh/keepresso/keepresso
If you installed the app from the DMG instead, the tool sits inside the app bundle and your PATH does not know about it yet. Link it once:
sudo ln -s /Applications/Keepresso.app/Contents/Helpers/keepresso /usr/local/bin/keepresso
Check it is wired up:
keepresso version
Control the app
These commands are delivered to the Keepresso app, launching it if it is not already running. They are the scriptable twin of the menu.
keepresso start # start an open-ended session
keepresso start --for 90 # start a 90 minute session
keepresso start --until 18:00 # run until a wall-clock time
keepresso stop # end the current session
keepresso toggle # flip it on or off
So a long job can wake the Mac when it begins and let it sleep when it finishes:
keepresso start
make release
keepresso stop
Read the status
keepresso status tells you whether a session is running, and its exit code makes it easy to branch on in a script:
0the Mac is being kept awake1it is not2the app is not running
keepresso status && echo "awake" || echo "asleep"
Add --json for a machine-readable answer:
keepresso status --json
The same session state is also mirrored to a file, so a menu-bar tool, a status line, or a widget can read it without launching anything:
~/Library/Application Support/Keepresso/status.json
It carries the current state and ISO 8601 timestamps.
Standalone holds, no app needed
Sometimes you do not want to involve the app at all, you just want this one shell to keep the Mac awake, exactly like caffeinate. In this mode the keepresso process itself holds the power assertion, and the Mac is free to sleep again the moment it exits.
keepresso -i # hold until you press Ctrl-C
keepresso -t 3600 # hold for a number of seconds
keepresso -w 5123 # hold until process 5123 exits
keepresso -d # also keep the display awake (combine with the above)
keepresso -u # declare user activity: wake the display now
The most useful pattern is tying wakefulness to the life of a command or a shell:
keepresso -w $$ & # stay awake as long as this shell lives
ffmpeg -i in.mov out.mp4 && keepresso stop
Because these holds are real macOS power assertions, they show up in pmset -g assertions and in Keepresso's own Activity pane, right alongside every other app holding the Mac up.
Related
- Control Keepresso from Shortcuts, Raycast, or a script covers the Shortcuts actions and the
keepresso://URL scheme for no-terminal automation. - A caffeinate alternative for macOS explains how Keepresso relates to the built-in
caffeinatecommand.
Get Keepresso
Free and open source, for macOS 14 and newer. Install it and keep your Mac awake on your terms.
More in Using Keepresso