Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

idx search for filesystem

Search indexed file contents.

Signature

> idx search {flags} ...rest

Flags

  • --regex, -r: Use regular-expression matching mode.
  • --fuzzy, -f: Use fuzzy line-matching mode.
  • --limit, -l {int}: Maximum number of matches to collect.
  • --context, -c {oneof<range, int>}: The number of context lines to include before and after each match can be specified as an integer or a range. An integer sets both the before and after context to that number, while a range uses a negative value for lines before and a positive value for lines after (e.g., -3..5).

Parameters

  • ...rest: One or more search patterns.

Input/output types:

inputoutput
nothinglist<record>

Examples

Search indexed file contents for a plain text pattern.

> idx search hello

Search using a regular expression.

> idx search --regex 'fn \w+'

Search with multiple patterns simultaneously.

> idx search TODO FIXME HACK

Include 2 lines of context before and 5 lines after each match.

> idx search error -2..5

Brackets and question marks are treated as literal text, not glob patterns.

> idx search 'arr[0]'

Glob patterns with a path separator filter which files to search.

> idx search pattern tests/*

Brace expansion globs also filter which files to search.

> idx search pattern *.{rs,js}

Notes

Mode selection: plain text is the default and treats each pattern literally, --regex evaluates the patterns as regular expressions, and --fuzzy performs approximate line matching.