mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 14:47:47 +00:00
Feature/add git grep completions (#898)
Added completions for most of the flags for `git grep`.
A few flags have been omitted for this PR due to Git expecting arguments
for those be passed without whitespaces. The arguments are optional, but
the flags would not work when passed arguments (see `--open-with-pager`
and `--color` flags in [this
commit](ffa9ceab73
)
for how I tried to do it).
Ex.
`--open-with-pager(-O)` expects the optional argument to be passed as
either `--open-with-pager=<pager>` or `-O<pager>`. Including it in the
completions list as I had implemented it breaks the flag when using the
optional parameter.
Feedback appreciated for how to handle that. I'm still new to the Nu
language, so I might have missed something obvious that could fix that.
This commit is contained in:
parent
71f5736d93
commit
0906f7a15c
1 changed files with 52 additions and 0 deletions
|
@ -709,3 +709,55 @@ export extern "git restore" [
|
|||
--pathspec-file-nul # Separate pathspec elements with NUL character when reading from file
|
||||
...pathspecs: string@"nu-complete git files" # Target pathspecs to restore
|
||||
]
|
||||
|
||||
# Print lines matching a pattern
|
||||
export extern "git grep" [
|
||||
--help(-h) # Display the help message for this command
|
||||
--cached # Search blobs registered in the index file instead of worktree
|
||||
--untracked # Include untracked files in search
|
||||
--no-index # Similar to `grep -r`, but with additional benefits, such as using pathspec patterns to limit paths; Cannot be used together with --cached or --untracked
|
||||
--no-exclude-standard # Include ignored files in search (only useful with --untracked)
|
||||
--exclude-standard # No not include ignored files in search (only useful with --no-index)
|
||||
--recurse-submodules # Recursively search in each submodule that is active and checked out
|
||||
--text(-a) # Process binary files as if they were text
|
||||
--textconv # Honor textconv filter settings
|
||||
--no-textconv # Do not honor textconv filter settings (default)
|
||||
--ignore-case(-i) # Ignore case differences between patterns and files
|
||||
-I # Don’t match the pattern in binary files
|
||||
--max-depth: int # Max <depth> to descend down directories for each pathspec. A value of -1 means no limit.
|
||||
--recursive(-r) # Same as --max-depth=-1
|
||||
--no-recursive # Same as --max-depth=0
|
||||
--word-regexp(-w) # Match the pattern only at word boundary
|
||||
--invert-match(-v) # Select non-matching lines
|
||||
-H # Suppress filename in output of matched lines
|
||||
--full-name # Force relative path to filename from top directory
|
||||
--extended-regexp(-E) # Use POSIX extended regexp for patterns
|
||||
--basic-regexp(-G) # Use POSIX basic regexp for patterns (default)
|
||||
--perl-regexp(-P) # Use Perl-compatible regular expressions for patterns
|
||||
--line-number(-n) # Prefix the line number to matching lines
|
||||
--column # Prefix the 1-indexed byte-offset of the first match from the start of the matching line
|
||||
--files-with-matches(-l) # Print filenames of files that contains matches
|
||||
--name-only # Same as --files-with-matches
|
||||
--files-without-match(-L) # Print filenames of files that do not contain matches
|
||||
--null(-z) # Use \0 as the delimiter for pathnames in the output, and print them verbatim
|
||||
--only-matching(-o) # Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line
|
||||
--count(-c) # Instead of showing every matched line, show the number of lines that match
|
||||
--no-color # Same as --color=never
|
||||
--break # Print an empty line between matches from different files.
|
||||
--heading # Show the filename above the matches in that file instead of at the start of each shown line.
|
||||
--show-function(-p) # Show the preceding line that contains the function name of the match, unless the matching line is a function name itself.
|
||||
--context(-C): int # Show <num> leading and trailing lines, and place a line containing -- between contiguous groups of matches.
|
||||
--after-context(-A): int # Show <num> trailing lines, and place a line containing -- between contiguous groups of matches.
|
||||
--before-context(-B): int # Show <num> leading lines, and place a line containing -- between contiguous groups of matches.
|
||||
--function-context(-W) # Show the surrounding text from the previous line containing a function name up to the one before the next function name
|
||||
--max-count(-m): int # Limit the amount of matches per file. When using the -v or --invert-match option, the search stops after the specified number of non-matches.
|
||||
--threads: int # Number of grep worker threads to use. Use --help for more information on grep threads.
|
||||
-f: string # Read patterns from <file>, one per line.
|
||||
-e: string # Next parameter is the pattern. Multiple patterns are combined by --or.
|
||||
--and # Search for lines that match multiple patterns.
|
||||
--or # Search for lines that match at least one of multiple patterns. --or is implied between patterns without --and or --not.
|
||||
--not # Search for lines that does not match pattern.
|
||||
--all-match # When giving multiple pattern expressions combined with --or, this flag is specified to limit the match to files that have lines to match all of them.
|
||||
--quiet(-q) # Do not output matched lines; instead, exit with status 0 when there is a match and with non-zero status when there isn’t.
|
||||
...pathspecs: string # Target pathspecs to limit the scope of the search.
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue