NotifyMe is a simple Bash utility that sends mobile notifications about the success or failure of terminal commands. This guide will walk you through the setup and usage of NotifyMe, making it easier to stay informed about your terminal tasks.
- Receive notifications on your mobile device when terminal commands complete.
- Distinguish between successful and failed tasks.
- Works seamlessly with Pushbullet for mobile notifications.
- Operating System: macOS or Linux.
- Dependencies:
curl: For sending HTTP requests.- Pushbullet account and API key.
- Installed Software:
- Pushbullet CLI (
pb) or equivalent notification service.
- Pushbullet CLI (
If you haven’t already installed the Pushbullet CLI:
brew install --cask pbAdd the following function to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.bash_profile):
notifyme() {
local pb="/Users/sumedh/Library/Python/3.9/bin/pb"
# Handle direct message mode
if [[ "$1" == "-m" && -n "$2" ]]; then
local msg="$2"
PYTHONWARNINGS=ignore "$pb" push "$msg"
return
fi
# Otherwise, run the given command
"$@"
local status=$? #The Status code of the failed command
local cmd="$*"
PYTHONWARNINGS=ignore "$pb" push "$(
if [ $status -eq 0 ]; then
echo "✅ [Task Completed!]:: $cmd"
else
echo "❌ [Task Failed!]:: $cmd"
fi
)"
}
Reload your shell configuration:
source ~/.zshrc # or the appropriate file for your shell- Log in to your Pushbullet account.
- Go to Pushbullet API Settings and create an access token.
- Save the token for later use (the
pbCLI uses it automatically if configured).
Run this command to test notifications:
pb push "Test notification from NotifyMe!"notifyme <command>notifyme ls- Notification: ✅ Task 'ls' completed!
notifyme ls nonexistent_folder- Notification: ❌ Task 'ls nonexistent_folder' failed!
- The
notifymefunction runs the provided command. - It checks the command’s exit status (
$?):- Success (exit status
0): Sends a success notification. - Failure (non-zero exit status): Sends a failure notification.
- Success (exit status
- NotifyMe supports chaining commands:
notifyme "echo Hello && echo World" - Avoid using commands that require user input, as NotifyMe works best with commands that complete automatically.
- No Notifications Received:
- Ensure the Pushbullet CLI (
pb) is installed and working. - Verify your Pushbullet API key.
- Ensure the Pushbullet CLI (
- Command Errors:
- Double-check your command syntax.
Contributions are welcome! Feel free to fork this repository and submit a pull request.
This project is licensed under the MIT License.