mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-11-07 08:14:02 +01:00
batgrep: Add support for ripgrep-all
To use `ripgrep-all`, add the `--rga` flag when running batgrep.
This commit is contained in:
parent
82911b5b7b
commit
5011f0709e
@ -31,7 +31,8 @@ Search through files or directories looking for matching regular expressions (or
|
||||
| | `--paging=["never"/"always"]`| Enable/disable paging. |
|
||||
| | `--pager=[PAGER]` | Specify the pager to use. |
|
||||
| | `--terminal-width=[COLS]` | Generate output for the specified terminal width. |
|
||||
| | `--no-separator` | Disable printing separator between files |
|
||||
| | `--no-separator` | Disable printing separator between files. |
|
||||
| | `--rga` | Use `ripgrep-all` instead of `ripgrep`. |
|
||||
|
||||
The following options are passed directly to ripgrep, and are not handled by this script.
|
||||
|
||||
|
@ -97,7 +97,10 @@ Options:
|
||||
Generate output for the specified terminal width.
|
||||
|
||||
--no-separator:
|
||||
Disable printing separator between files
|
||||
Disable printing separator between files.
|
||||
|
||||
--rga:
|
||||
Use ripgrep-all instead of ripgrep.
|
||||
|
||||
Options passed directly to ripgrep:
|
||||
-F, --fixed-strings
|
||||
@ -141,6 +144,7 @@ EOF
|
||||
# -----------------------------------------------------------------------------
|
||||
# Options:
|
||||
# -----------------------------------------------------------------------------
|
||||
RIPGREP="$EXECUTABLE_RIPGREP"
|
||||
RG_ARGS=()
|
||||
BAT_ARGS=()
|
||||
PATTERN=""
|
||||
@ -252,6 +256,14 @@ while shiftopt; do
|
||||
-p | --search-pattern) OPT_SEARCH_PATTERN=true ;;
|
||||
--no-search-pattern) OPT_SEARCH_PATTERN=false ;;
|
||||
--no-separator) OPT_NO_SEPARATOR=true ;;
|
||||
--rga) {
|
||||
if ! rga --version | grep 'ripgrep-all' &>/dev/null; then
|
||||
printc "%{RED}%s: option '--rga' requires ripgrep-all to be installed%{CLEAR}\n" "$PROGRAM" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RIPGREP='rga'
|
||||
};;
|
||||
|
||||
# Option forwarding
|
||||
--rg:*) {
|
||||
@ -377,10 +389,10 @@ main() {
|
||||
)
|
||||
|
||||
if "$READ_FROM_STDIN"; then
|
||||
"$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA"
|
||||
"$RIPGREP" "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA"
|
||||
return $?
|
||||
else
|
||||
"$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}"
|
||||
"$RIPGREP" "${COMMON_RG_ARGS[@]}"
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ Options:
|
||||
Generate output for the specified terminal width.
|
||||
|
||||
--no-separator:
|
||||
Disable printing separator between files
|
||||
Disable printing separator between files.
|
||||
|
||||
--rga:
|
||||
Use ripgrep-all instead of ripgrep.
|
||||
|
||||
Options passed directly to ripgrep:
|
||||
-F, --fixed-strings
|
||||
|
Loading…
Reference in New Issue
Block a user