]> gitweb.fluxo.info Git - scripts.git/commitdiff
Improve the 'show' command
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Jul 2023 14:20:34 +0000 (11:20 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Jul 2023 14:20:34 +0000 (11:20 -0300)
show

diff --git a/show b/show
index aa8c5393d91cf43e430966b0b0edc040a2acb9ac..a68264b8f03f51523f17b4d8e76fe523480b4757 100755 (executable)
--- a/show
+++ b/show
@@ -34,7 +34,7 @@ function __update_filelist {
 
 # Check
 if [ -z "$ITEM" ]; then
-  echo "usage: $BASENAME <item-name>"
+  echo "usage: $BASENAME [option] [<item-name>]"
   exit 1
 elif [ "$ITEM" == "--refresh" ]; then
   __update_filelist
@@ -74,8 +74,15 @@ elif [ "$ITEM" == "--watch" ]; then
     $PROGRAM --refresh
   done
 else
+  if [ "${ITEM:0:2}" == "--" ] && [ ! -z "$OPTION" ]; then
+    OPEN="${ITEM:2}"
+    ITEM="$OPTION"
+  else
+    OPEN="xdg-open"
+  fi
+
   grep -i -- "$ITEM" $LIST | while read entry; do
     echo "Opening $entry..."
-    cd $DOCS && xdg-open "$entry"
+    cd $DOCS && $OPEN "$entry"
   done
 fi