1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Added find_in command to search files (#972)

This commit is contained in:
Blake Miner 2024-10-16 22:27:23 -04:00 committed by GitHub
parent c05790d2fc
commit c67a6959fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}