Did a quick check on OSX. `osascript` seems to return the window id of the Terminal app running on the remote host. Unless the Terminal window on the remote host has focus,  `[[ $focus_window_id == $terminal_window_id ]]` will return false, and will show a notification window on the remote host after completing any command.

I updated the pull request with the `if_ssh` block