The simplest way would be to invoke a notification using Applescript after a given terminal command like so:
npm run build && osascript -e 'display notification "Complete" with title "npm run build"'
The next level would be to create a custom script in package.json
:
"scripts": {
"build-notify": "npm run build && osascript -e 'display notification \"Complete\" with title \"npm run build\"'"
}
Another option would be to create a custom alias to run the whole thing:
alias build="npm run build && osascript -e 'display notification \"Complete\" with title \"Build complete\"'"
Then run it like a regular terminal command: build
If you don't mind the audio, you could use the say
command instead:
npm run build && say done
.
There are also some tools that abstract this a bit, like https://github.com/julienXX/terminal-notifier and maybe many more.