mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +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.
|
# Search terms in the specified files and/or folders based on the glob pattern provided.
|
||||||
def "find in" [
|
def "find in" [
|
||||||
glob: glob, # the glob expression
|
glob: glob, # The glob expression
|
||||||
...rest: any # terms to search
|
--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> {
|
]: nothing -> table<path: string, line: int, data: string> {
|
||||||
glob --no-dir $glob
|
glob --exclude $exclude --no-dir $glob
|
||||||
| par-each {|e|
|
| par-each {|e|
|
||||||
open $e | lines | enumerate | rename line data |
|
open --raw $e | lines | enumerate | rename line data |
|
||||||
find --columns [data] ...$rest |
|
find --columns [data] ...$rest |
|
||||||
each {|match| {path: ($e | path relative-to $env.PWD), ...$match}}
|
each {|match| {path: ($e | path relative-to $env.PWD), ...$match}}
|
||||||
} | flatten
|
} | flatten
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue