Browse Source

Merge branch 'master' of git.galthub.com:gmj/home.public.bash

George Jones 1 year ago
parent
commit
56423419df
1 changed files with 41 additions and 1 deletions
  1. 41 1
      rc.local/bash_funcs.sh

+ 41 - 1
rc.local/bash_funcs.sh

@@ -32,6 +32,8 @@ Examples:
   gf BEGIN\|END .org 7
 EOF
 
+# TODO re-write this with ligitimate getopt parsing so things like this work
+# find . -mtime -360 -type f -name \*.org -exec grep -H "that were blocked" \{\} \;
 
         if [[ "${message}" != "" ]]; then
            echo 2>&1
@@ -57,7 +59,7 @@ EOF
 
     cmd="find . -type f -mtime -${days} $files_flag -exec egrep --color=always -H -i ${regex} {} ;"
     debug "command: ${cmd}"
-    
+
     (exec $cmd)
 
 )
@@ -68,3 +70,41 @@ function csvls()
     # https://stackoverflow.com/questions/14573262/convert-ls-output-into-csv
     find . -ls | awk '{printf( "%s,%s,%s,%s,%s,%s,%s,%s %s %s,%s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11 )}'
 )
+
+
+# Grep out common "junk" files and directories.   Ubuntu/Linux specific.
+alias nojunk="egrep -vi \.snap\|\.config\|\.cache\|.git\|.local"
+
+# Find recently modified files or directories
+# The intent is to find "things I've been working on recently"
+
+function recentf ()
+# find recently modified files
+#
+# Usage: recentf [DIR [AGE]]
+#
+#  Defaults: DIR=., AGE=3
+{
+    # find recently modified files
+    #
+    # Usage: recentf [directory [days]]
+
+    find ${1:-.} -mtime -${2:-3} -print | \
+        nojunk | \
+        sort | \
+        uniq
+}
+
+
+function recentd ()
+{
+    # find directories with recently modified files
+    #
+    # Usage: recentd [directory [days]]
+
+    find ${1:-.} -mtime -${2:-3} -print | \
+        nojunk | \
+        sed 's#/[^/]*$##' | \
+        sort | \
+        uniq
+}