3 ms·
Show OS X notification when long running cmd finishes and terminal not in focus
- eridius 10y agoClever, but compiling and executing an AppleScript every single time any command finishes seems a bit overkill. Does zsh have a way to see how long the last command took? You could at least have this only do the check if the command took more than one or two seconds. That would cut out a lot of the unnecessary checks.
- mayoff 10y agoYou could pre compile the script with osacompile if you want, but I wouldn't bother. I think checking the command runtime would be a mistake. If you expect the command to take a long time, and it finished in just a second or two, you probably want to be notified immediately rather than eventually wondering many minutes later why you weren't. And if you expect the command to take only a second or two, you are a lot less likely to be tabbing away, so you won't be notified anyway.
- dandelany 10y agoMy lightweight solution is to append `&& tput bel` to long-running commands, to ring the terminal bell upon completion :) Requires sound of course, but it's reasonably easy to remember and quick to type. eg. try `sleep 5 && tput bel` I've also used a similar cheap hack to listen to web traffic... Just write a bell character to your server log when something interesting happens, then `tail -f` the log file for live data sonification!
- hyperjeff 10y agoalso fun is to append `osascript -e 'say "all done!"'` or somesuch if you're within decent earshot. you can even pipe in context-specific info.
- jason_slack 10y agoThis might be useful to me. What is the app in the foreground, in the screenshot at the bottom? Looks like a multi-tabbed text editor?
- cozzyd 10y agoGnome-terminal does this out of the box, but it doesn't work in tmux or over SSH connections.