Display notification after end of command execution
Published in
1 min readJan 22, 2017
I have a problem: while long time tasks executed in terminal, I switch to safari, forgetting about the work. Before now I used || echo -e "\a"
, but it's not working while my plugged headphones lie on a table.
Now I find better solution. With osascript
you can send mac os notifications from terminal:
You can configure text, title, subtitle and sound. Here is code example:
osascript -e 'display notification "task execution completed" with title "terminal" sound name "Ping.aiff"'
Sound can be selected from ~/Library/Sounds
or /System/Library/Sounds
.
And few aliases I use:
# type it after long time command: `... && notify`
alias notify="osascript -e 'display notification \"task execution completed\" with title \"terminal\" sound name \"Ping.aiff\"'"# install pods with notification
alias pi="pod install && osascript -e 'display notification \"cocoapods installed\" with title \"terminal\" sound name \"Ping.aiff\"'"# install pods with updating repo and notification
alias piu="pod install --repo-update && osascript -e 'display notification \"cocoapods installed\" with title \"terminal\" sound name \"Ping.aiff\"'"# update git and pods with notification
alias good_morning="git checkout develop && git pull -r && piu"