When I kick off a long running process on a project (e.g.
npm install) and I shift my focus somewhere else, I often get absorbed in my other task and don’t return to the original process as soon as I wanted to. I’ve addressed this in the past by setting a timer to remind me to come back and check. More recently, I’ve started adding a audio notification to tell me when the task is completed.
npm install && say 'Task complete'
I’m on a Mac, which has the say command in the default install, so when the commands complete the machine now says “Task complete”.
What About Failures
This has been a great improvement for me. However, there have been times the command failed, which resulted in the notification not playing. It would be helpful to be notified of a failure as well, which we can do using the or (
npm install && say 'Task complete' || say 'Failure'
I’ve started doing this so often, I’ve added an alias to my zsh configuration called
alias sayresult="say 'Task complete' || say 'Failure'"
Now I can run
npm install && sayresult
Chaining in Other Commands
I can also use
&& to chain in other commands. For example:
npm install && npm run build && sayresult
composer install && npm install && npm run build && sayresult