Files
dotfiles/dot_config/nushell/nu_scripts/sourced/cool-oneliners/find_in.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

13 lines
429 B
Nu

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