Skip to content

Commit f9b9636

Browse files
authored
Improved find in: add --exclude flag and properly open files (#1059)
1 parent 096daa4 commit f9b9636

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sourced/cool-oneliners/find_in.nu

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Search terms in the specified files and/or folders based on the glob pattern provided.
22
def "find in" [
3-
glob: glob, # the glob expression
4-
...rest: any # terms to search
3+
glob: glob, # The glob expression
4+
--exclude (-e): list<string> # Patterns to exclude from the search: `find in` will not walk the inside of directories matching the excluded patterns.
5+
...rest: any # Terms to find
56
]: nothing -> table<path: string, line: int, data: string> {
6-
glob --no-dir $glob
7+
glob --exclude $exclude --no-dir $glob
78
| par-each {|e|
8-
open $e | lines | enumerate | rename line data |
9+
open --raw $e | lines | enumerate | rename line data |
910
find --columns [data] ...$rest |
1011
each {|match| {path: ($e | path relative-to $env.PWD), ...$match}}
1112
} | flatten

0 commit comments

Comments
 (0)