mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-31 14:17:45 +00:00
Added find_in command to search files (#972)
This commit is contained in:
parent
c05790d2fc
commit
c67a6959fc
1 changed files with 12 additions and 0 deletions
12
sourced/cool-oneliners/find_in.nu
Normal file
12
sourced/cool-oneliners/find_in.nu
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue