Verified Commit bf0ee50a authored by doshitan's avatar doshitan
Browse files

Mention watch and notifications on /shell

parent 8d68d4e1
......@@ -3,7 +3,7 @@ title: Shell
toc: true
toc-margin: true
published: 2019-04-16T11:23:06-05:00
modified: 2020-12-17T20:37:56-0500
modified: 2021-03-11T09:37:41-0500
I primarily use [[][Zsh]], though often must write code suitable for Bash for
......@@ -405,6 +405,43 @@ the shell (or @@html:<kbd>Ctrl-d</kbd>@@).
~:~ (a single colon) is equivalent to ~true~ in most shells. It can be useful as
a no-op on occasion or a quick way to ignore the failure of a command
(~command || :~), but often using ~true~ is more readable.
* Repeatedly run command
For the times you need to run a command repeatedly to monitor some thing,
there's ~watch~.
#+begin_src bash
watch -n1 df -h
Runs ~df -h~ every second, showing the latest output.
Just being able to poll something is useful enough, but some additional flags
can be very convenient:
- ~-b/--beep~ beep when command has a non-zero exit
- ~-d/--differences~ highlight changes between updates
* Notify when command finishes
Can beep with ~printf \\a~[fn::Or equivalently ~echo -en "\007"~ or ~echo -en
\\a~ ].
#+begin_src bash
sleep 5; printf \\a
When you want more than a beep, on Linux, ~espeak~ (likely provided by an
~espeak-ng~ package) or ~spd-say~ (default in recent Ubuntus) will play sound
via text-to-speech[fn::There are a good number of TTS engines for Linux, this
[[][StackOverflow question discusses some]].]:
#+begin_src bash
sleep 5; espeak "Fly, you fools!"
When you don't want sound, on Linux, display a notification with ~notify-send~
(provided by ~libnotify~):
#+begin_src bash
sleep 5; notify-send "Tea is ready."
* More resources
- [[][Greg's Wiki]] is a great resource, includes a [[][Bash FAQ]], [[][common
pitfalls]], [[][learning guide]], [[][reference sheet]], and more.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment