Keep your Mac awake
while GitHub Copilot works.
Copilot's agent mode works inside VS Code, and Copilot CLI in your terminal. Both run on your Mac and stop when it sleeps. Midnight Oil keeps the Mac awake while they work, even with the lid closed.
The short answer
In VS Code, add an App Running trigger for Visual Studio Code in Midnight Oil. With Copilot CLI, wrap the run: midnightoil run -- copilot -p "…". Or add one line to .github/copilot-instructions.md.
GitHub Copilot at a glance
| Runs where | VS Code agent mode, or Copilot CLI in your terminal |
| Interactive | The Chat view in agent mode, or copilot |
| Unattended | copilot -p "…" runs one prompt and exits |
| Instructions file | .github/copilot-instructions.md or AGENTS.md; ~/.copilot/copilot-instructions.md for the CLI everywhere |
| Needs your Mac awake? | Yes for agent mode and the CLI. Copilot's coding agent on GitHub runs in the cloud and doesn't. |
What happens when your Mac sleeps mid-run
Agent mode runs in VS Code, and Copilot CLI in your terminal. When the Mac sleeps, both freeze: the model request is cut off, terminal commands pause, and the task waits for you.
An open VS Code window doesn't stop macOS from sleeping, and nothing does once the lid closes.
Just ask GitHub Copilot
With Midnight Oil installed, GitHub Copilot can run the midnightoil command for you. Say it in your own words:
| You say | GitHub Copilot runs |
|---|---|
| “Keep my Mac awake until you're done with this.” | midnightoil start |
| “Run the build and keep the Mac awake for it.” | midnightoil run -- npm run build |
| “Let my Mac sleep now.” | midnightoil stop |
The session shows up in the menu bar like one you started yourself, so you can see it, extend it, or end it with a click.
Make it automatic
Add this line to .github/copilot-instructions.md and GitHub Copilot keeps the Mac awake for every long command without being asked:
midnightoil --help for the rest.For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.
Running GitHub Copilot unattended
In VS Code: Midnight Oil's Settings › Triggers › Add Trigger › App Running › Visual Studio Code keeps the Mac awake whenever VS Code is open. Agent mode can also run midnightoil in its terminal when you ask.
Copilot CLI: copilot -p runs one prompt without the interactive UI. Wrap it in midnightoil run and the Mac stays awake until it exits, with Copilot's exit code passed through.
The coding agent on GitHub, the one you assign issues to, runs in GitHub Actions, so it doesn't need your Mac at all.
Keep the Mac awake for the whole session
midnightoil run -- copilot
Or for one unattended run
midnightoil run --lid-closed -- copilot -p "fix the flaky checkout test"
Lid closed, battery safe
Add --lid-closed and GitHub Copilot keeps working with the laptop shut. It needs a one-time approval in Midnight Oil's Settings › Closed Lid, and normal sleep comes back the moment the session ends, even if the app quits or crashes.
On battery, sessions can end when you unplug or drop below a level you pick, and an alarm sounds if the lid closes during a closed-lid session. Add --allow-display-sleep to let the screen go dark while the Mac keeps working. The full setup is in how to run AI agents overnight.
Questions
Does Copilot agent mode keep working while my Mac sleeps?
No. VS Code and the agent pause with the Mac. Copilot's coding agent on GitHub is different: it runs in the cloud.
Where does the instruction go?
In .github/copilot-instructions.md or AGENTS.md at the repo root. The line: For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.
Can I keep the Mac awake only while VS Code is open?
Yes. Add an App Running trigger for Visual Studio Code in Midnight Oil's Settings › Triggers.
Using another agent?
Let GitHub Copilot work the night shift.
Free. No account, no subscription.
macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/midnightoil