ソースを参照

Use environment variables for options

George Jones 1 年間 前
コミット
c3312bdbff
1 ファイル変更16 行追加4 行削除
  1. 16 4
      rc.local/find-aliases.sh

+ 16 - 4
rc.local/find-aliases.sh

@@ -6,10 +6,22 @@ function lo {
 }
 
 function gorg (
-    # grep or WHAT in org files in the current directolry younger than AGE
+    # grep fro WHAT in org (or EXT) files in the current directolry younger than AGE
+    #
+    # Usage:
+    #   [GF=-i] [EXT=.org] [WHERE=$HOME] gorg [WHAT [AGE]]
+    #
+    # Enviornment Variables:
+    #   WHAT   - regexp to serach for
+    #   WHERE  - WHERE to search.  Default "."
+    #   AGE    - files not older than AGE days.  Default 7.
+    #   EXT    - Search files of this extention.  Default ".org"
+    #   GF     - used for grep flags.  Set to "GF=-i" for case-insensitive
+    #   DEBUG  - set to "1" for debugging
+    #
     WHAT=${1:-.org};
     AGE=${2:-7};
-    debug WHAT $WHAT;
-    debug AGE $AGE;
-    find . -name \*.org -mtime -${AGE} -exec grep -i --color=always -H -e  "${WHAT}" \{\} \;
+    [[ -v DEBUG ]] && set -x
+    find ${WHERE:-.} -name \*.${EXT:-org} -mtime -${AGE} -exec grep ${GF:-} --color=always -H -e  "${WHAT}" \{\} \;
+    [[ -v DEBUG ]] && set +x
 )