mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-31 06:07:44 +00:00
Improved find in
: add --exclude
flag and properly open files (#1059)
This commit is contained in:
parent
096daa436d
commit
f9b9636003
1 changed files with 5 additions and 4 deletions
|
@ -1,11 +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
|
||||
glob: glob, # The glob expression
|
||||
--exclude (-e): list<string> # Patterns to exclude from the search: `find in` will not walk the inside of directories matching the excluded patterns.
|
||||
...rest: any # Terms to find
|
||||
]: nothing -> table<path: string, line: int, data: string> {
|
||||
glob --no-dir $glob
|
||||
glob --exclude $exclude --no-dir $glob
|
||||
| par-each {|e|
|
||||
open $e | lines | enumerate | rename line data |
|
||||
open --raw $e | lines | enumerate | rename line data |
|
||||
find --columns [data] ...$rest |
|
||||
each {|match| {path: ($e | path relative-to $env.PWD), ...$match}}
|
||||
} | flatten
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue