mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-01-05 20:58:51 +01:00
Update batgrep to disabled highlights when -C=0
This commit is contained in:
parent
daa54ba4cf
commit
c8e22890fe
@ -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.<br /><br />This is disabled when `--context=0` or when `bat --version` is less than `0.12.x`. |
|
||||
| | `--no-snip` | Do not show the `snip` decoration.<br /><br />This is automatically enabled when `--context=0` or when `bat --version` is less than `0.12.x`. |
|
||||
| | `--no-highlight` | Do not highlight matching lines.<br /><br />This is automatically enabled when `--context=0`. |
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user