Skip to content

Commit

Permalink
Added find_in command to search files
Browse files Browse the repository at this point in the history
  • Loading branch information
bminer committed Oct 17, 2024
1 parent c05790d commit 9b98c4b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sourced/cool-oneliners/find_in.nu
Original file line number Diff line number Diff line change
@@ -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<path: string, line: int, data: string> {
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
}

0 comments on commit 9b98c4b

Please sign in to comment.