mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-13 09:40:42 +01:00
batgrep: Add simple parsing of RIPGREP_CONFIG_PATH.
This commit is contained in:
parent
dc50f28480
commit
5f5023d056
@ -45,6 +45,46 @@ if version_compare "$(bat_version)" -gt "0.12"; then
|
||||
OPT_SNIP=",snip"
|
||||
fi
|
||||
|
||||
# Parse RIPGREP_CONFIG_PATH.
|
||||
if [[ -n "$RIPGREP_CONFIG_PATH" && -e "$RIPGREP_CONFIG_PATH" ]]; then
|
||||
# shellcheck disable=SC2013
|
||||
for arg in $(cat "$RIPGREP_CONFIG_PATH"); do
|
||||
case "$arg" in
|
||||
--context=*)
|
||||
val="${arg:10}"
|
||||
OPT_CONTEXT_BEFORE="$val"
|
||||
OPT_CONTEXT_AFTER="$val"
|
||||
;;
|
||||
|
||||
--before-context=*)
|
||||
val="${arg:17}"
|
||||
OPT_CONTEXT_BEFORE="$val"
|
||||
;;
|
||||
|
||||
--after-context=*)
|
||||
val="${arg:16}"
|
||||
OPT_CONTEXT_AFTER="$val"
|
||||
;;
|
||||
|
||||
-C*)
|
||||
val="${arg:2}"
|
||||
OPT_CONTEXT_BEFORE="$val"
|
||||
OPT_CONTEXT_AFTER="$val"
|
||||
;;
|
||||
|
||||
-B*)
|
||||
val="${arg:2}"
|
||||
OPT_CONTEXT_BEFORE="$val"
|
||||
;;
|
||||
|
||||
-A*)
|
||||
val="${arg:2}"
|
||||
OPT_CONTEXT_AFTER="$val"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
# Parse arguments.
|
||||
while shiftopt; do
|
||||
case "$OPT" in
|
||||
|
Loading…
Reference in New Issue
Block a user