In my daily work it’s often a case when I have long-running process that I have to wait for to complete and I don’t want to stare at the shell all the time.
Some terminal emulators do have features like “Monitor for Silence/Activity”,
gnome-terminal does not. That’s why I decided to build something more
shell-based and generic.
To do what I want I’ve created two commands. First is
tick that I store under
1 2 3 4 5
I use it during daily work, and in some of my scripts to play simple, short “tick”.
notify, which is a bit more extensive notification command. The
1 2 3 4 5 6 7 8 9
Not only it plays longer and louder alarm sound, but additionally it uses
notify-send to display notification on your desktop so you know exactly what
notify into ZSH
In a depth of my complex ZSH configuration I do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
So what does it do? First, before execution of every command
record current timestamp and command that is about to be executed. Then, after
command has finished, but before the new prompt is displayed
precmd will call
line-tick to check what should be done.
line-tick will compare the current
timestamp with the one recorded by
preexec. If the time spent on execution of
the command is longer than 60 seconds,
notify command will be triggered to
tell us what command has finished and play alarm sound. If the command
execution time was smaller, but still longer than 10 seconds
tick will be