diff --git a/doc/batgrep.md b/doc/batgrep.md
index ff11274..99e9916 100644
--- a/doc/batgrep.md
+++ b/doc/batgrep.md
@@ -21,7 +21,8 @@ A script that combines [ripgrep](https://github.com/burntsushi/ripgrep) with bat
| `-B` | `--before-context=[LINES]` | Display the previous `n` lines before a matched line. |
| `-C` | `--context=[LINES]` | A combination of `--after-context` and `--before-context`. |
| | `--no-follow` | Do not follow symlinks. |
-| | `--no-snip` | Do not show the `snip` decoration.
This is disabled when `--context=0` or when `bat --version` is less than `0.12.x`. |
+| | `--no-snip` | Do not show the `snip` decoration.
This is automatically enabled when `--context=0` or when `bat --version` is less than `0.12.x`. |
+| | `--no-highlight` | Do not highlight matching lines.
This is automatically enabled when `--context=0`. |
diff --git a/src/batgrep.sh b/src/batgrep.sh
index 137b02d..294c191 100755
--- a/src/batgrep.sh
+++ b/src/batgrep.sh
@@ -20,6 +20,7 @@ OPT_CONTEXT_BEFORE=2
OPT_CONTEXT_AFTER=2
OPT_FOLLOW=true
OPT_SNIP=""
+OPT_HIGHLIGHT=true
BAT_STYLE="header,numbers"
# Set options based on the bat version.
@@ -63,6 +64,7 @@ while shiftopt; do
# Script Options
--no-follow) OPT_FOLLOW=false;;
--no-snip) OPT_SNIP="";;
+ --no-highlight) OPT_HIGHLIGHT=false;;
# ???
-*) {
@@ -92,6 +94,7 @@ fi
if [[ "$OPT_CONTEXT_BEFORE" -eq 0 && "$OPT_CONTEXT_AFTER" -eq 0 ]]; then
OPT_SNIP=""
+ OPT_HIGHLIGHT=false
fi
# Invoke ripgrep.
@@ -137,7 +140,7 @@ while IFS=':' read -r file line column; do
[[ "$line_start" -gt 0 ]] || line_start=''
LAST_LR+=("--line-range=${line_start}:${line_end}")
- LAST_LH+=("--highlight-line=${line}")
+ [[ "$OPT_HIGHLIGHT" = "true" ]] && LAST_LH+=("--highlight-line=${line}")
done < <(rg --with-filename --vimgrep "${RG_ARGS[@]}" --sort path "$PATTERN" "${FILES[@]}")
do_print