Shell one-liners
A push() function and one-liners for scripts, cron jobs and long commands.
The quickest way to get a notification from a terminal, a script or a cron job is a hook: one curl with a title header, no JSON and no API key. Create a hook on the recipient's page in the dashboard and keep its URL in an environment variable:
⫻
shell
A push function#
Add this to ~/.bashrc or ~/.zshrc, or to the top of a script:
⫻
push()
- The first argument is the title. The second, if given, is the body; otherwise the body is read from a pipe.
PUSH_PRIORITYsets the priority with the hook's values:low,default,highorurgent.defaultsends with priorityhigh.--fail-with-bodymakespushfail with curl's exit code and print Push's error when the request is refused. It needs curl 7.76 or later; drop it on older systems.
⫻
usage
When a long command finishes#
Run the command, then report its exit code. $? is read before push runs, so it is the command's own code:
⫻
shell
Only when something fails#
|| runs push only when the command before it exits with an error:
Without the function#
Where defining a function is not handy, one curl does the same:
⫻
curl
In a crontab#
Cron does not read your shell profile, so set the hook URL at the top of the crontab and call curl directly:
⫻
crontab -e
% specially in a command line. Keep date formats like +%F in a script rather than in the crontab line.With an API key and safe retries#
To send through the API instead, for example to pick the recipient or use message options, post JSON with an API key. An Idempotency-Key (up to 255 characters) tied to the job lets curl retry without sending twice. This version uses jq to build the JSON safely:
- Pick a key that names the event, like
backup-2026-10-05. Running the same job twice in a day then sends one notification, and a retry after a network error replays the first answer. See Idempotency. --retry-all-errorsneeds curl 7.71 or later.- Keep
PUSH_API_KEYon the server. Live keys are refused from browsers; see Authentication.