mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-02-07 20:59:12 +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. |
|
| | `--paging=["never"/"always"]`| Enable/disable paging. |
|
||||||
| | `--pager=[PAGER]` | Specify the pager to use. |
|
| | `--pager=[PAGER]` | Specify the pager to use. |
|
||||||
| | `--terminal-width=[COLS]` | Generate output for the specified terminal width. |
|
| | `--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.
|
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.
|
Generate output for the specified terminal width.
|
||||||
|
|
||||||
--no-separator:
|
--no-separator:
|
||||||
Disable printing separator between files
|
Disable printing separator between files.
|
||||||
|
|
||||||
|
--rga:
|
||||||
|
Use ripgrep-all instead of ripgrep.
|
||||||
|
|
||||||
Options passed directly to ripgrep:
|
Options passed directly to ripgrep:
|
||||||
-F, --fixed-strings
|
-F, --fixed-strings
|
||||||
@ -141,6 +144,7 @@ EOF
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Options:
|
# Options:
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
RIPGREP="$EXECUTABLE_RIPGREP"
|
||||||
RG_ARGS=()
|
RG_ARGS=()
|
||||||
BAT_ARGS=()
|
BAT_ARGS=()
|
||||||
PATTERN=""
|
PATTERN=""
|
||||||
@ -252,6 +256,14 @@ while shiftopt; do
|
|||||||
-p | --search-pattern) OPT_SEARCH_PATTERN=true ;;
|
-p | --search-pattern) OPT_SEARCH_PATTERN=true ;;
|
||||||
--no-search-pattern) OPT_SEARCH_PATTERN=false ;;
|
--no-search-pattern) OPT_SEARCH_PATTERN=false ;;
|
||||||
--no-separator) OPT_NO_SEPARATOR=true ;;
|
--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
|
# Option forwarding
|
||||||
--rg:*) {
|
--rg:*) {
|
||||||
@ -377,10 +389,10 @@ main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "$READ_FROM_STDIN"; then
|
if "$READ_FROM_STDIN"; then
|
||||||
"$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA"
|
"$RIPGREP" "${COMMON_RG_ARGS[@]}" <<< "$STDIN_DATA"
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
"$EXECUTABLE_RIPGREP" "${COMMON_RG_ARGS[@]}"
|
"$RIPGREP" "${COMMON_RG_ARGS[@]}"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,10 @@ Options:
|
|||||||
Generate output for the specified terminal width.
|
Generate output for the specified terminal width.
|
||||||
|
|
||||||
--no-separator:
|
--no-separator:
|
||||||
Disable printing separator between files
|
Disable printing separator between files.
|
||||||
|
|
||||||
|
--rga:
|
||||||
|
Use ripgrep-all instead of ripgrep.
|
||||||
|
|
||||||
Options passed directly to ripgrep:
|
Options passed directly to ripgrep:
|
||||||
-F, --fixed-strings
|
-F, --fixed-strings
|
||||||
|
Loading…
Reference in New Issue
Block a user