]> gitweb.fluxo.info Git - scripts.git/commitdiff
Feat: show: inotify watch support
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 15 Apr 2021 11:14:38 +0000 (08:14 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 15 Apr 2021 11:14:38 +0000 (08:14 -0300)
show

diff --git a/show b/show
index 4be01acdf47f17e19842f50f31da75d5695a1b14..219570252456aeeb6294b3ec523069fc1758f6f1 100755 (executable)
--- a/show
+++ b/show
@@ -4,6 +4,7 @@
 #
 
 # Parameters
+PROGRAM="$0"
 BASENAME="`basename $0`"
 DOCS="$HOME/data/doc"
 FILELIST=".filelist"
@@ -59,6 +60,14 @@ fi
 if [ "$ITEM" == "--search" ]; then
   shift
   grep -i -- "$*" $LIST
+elif [ "$ITEM" == "--watch" ]; then
+  (
+    cd $DOCS
+
+    while inotifywait -e modify -e create -e move -e delete .; do
+      $PROGRAM --refresh
+    done
+  )
 else
   grep -i -- "$ITEM" $LIST | while read entry; do
     echo "Opening $entry..."