diff --git a/sourced/cool-oneliners/find_in.nu b/sourced/cool-oneliners/find_in.nu new file mode 100644 index 00000000..4f8dc503 --- /dev/null +++ b/sourced/cool-oneliners/find_in.nu @@ -0,0 +1,12 @@ +# Search terms in the specified files and/or folders based on the glob pattern provided. +def "find in" [ + glob: glob, # the glob expression + ...rest: any # terms to search +]: nothing -> table { + glob $glob + | par-each {|e| + open $e | lines | enumerate | rename line data | + find -c [data] ...$rest | + each {|match| {path: ($e | path relative-to $env.PWD), ...$match}} + } | flatten +}