Skip to content

Instantly share code, notes, and snippets.

@ammunoz
Last active July 5, 2025 20:50
Show Gist options
  • Save ammunoz/dc583ee555ddfabb99bf40f3d12c27f8 to your computer and use it in GitHub Desktop.
Save ammunoz/dc583ee555ddfabb99bf40f3d12c27f8 to your computer and use it in GitHub Desktop.
Terminal Notify on Command Completion
@echo off
:: Check has at least one argument
if "%~1"=="" (
echo "Usage: notify.bat <command> [arguments...]"
exit /b 1
)
:: Run command
call %*
:: Call Python script to fire off notification
python "C:\path\to\script\notify.py" %*
#!/usr/bin/env python3
import sys
from plyer import notification
def show_notification(command):
notification.notify(
title="Task Complete",
message=f"The command '{command}' has finished.",
app_name="Command Notifier",
timeout=5 # Notification duration in seconds
)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python notify.py <command>")
else:
command = " ".join(sys.argv[1:])
show_notification(command)
#!/bin/bash
# Check has at least one argument
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <command> [arguments...]"
exit 1
fi
# Run command
"$@"
# Call Python script to fire off notification
python3 /path/to/notify.py "$*"
@ammunoz
Copy link
Author

ammunoz commented Jul 5, 2025

Prerequisites:

  • python3
  • pip
    python -m ensurepip --upgrade
  • plyer
    pip install plyer

Instructions:

  1. Place notify.bat or notify.sh is in directory that is in user PATH.
  2. Replace notify.bat with appropriate path to notify.py.
  3. Open cmd/bash and follow example usage:
    notify timeout /t 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment