From a3483a658afff2de7e3800c8f47be1e0801d63b1 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Mon, 23 Dec 2019 16:49:31 -0800 Subject: [PATCH] Add support for '--smart-case' to batgrep --- src/batgrep.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/batgrep.sh b/src/batgrep.sh index ec3a159..ff91675 100755 --- a/src/batgrep.sh +++ b/src/batgrep.sh @@ -24,6 +24,7 @@ RG_ARGS=() BAT_ARGS=() PATTERN="" FILES=() +OPT_CASE_SENSITIVITY='' OPT_CONTEXT_BEFORE=2 OPT_CONTEXT_AFTER=2 OPT_FOLLOW=true @@ -41,7 +42,9 @@ while shiftopt; do case "$OPT" in # Ripgrep Options - -i|--ignore-case) RG_ARGS+=("--ignore-case");; + -i|--ignore-case) OPT_CASE_SENSITIVITY="--ignore-case";; + -s|--case-sensitive) OPT_CASE_SENSITIVITY="--case-sensitive";; + -S|--smart-case) OPT_CASE_SENSITIVITY="--smart-case";; -A|--after-context) shiftval; OPT_CONTEXT_AFTER="$OPT_VAL";; -B|--before-context) shiftval; OPT_CONTEXT_BEFORE="$OPT_VAL";; -C|--context) shiftval; OPT_CONTEXT_BEFORE="$OPT_VAL"; @@ -100,6 +103,10 @@ fi SEP="$(printc "%{DIM}%$(tput cols)s%{CLEAR}" | sed "s/ /─/g")" # Append ripgrep and bat arguments. +if [[ -n "$OPT_CASE_SENSITIVITY" ]]; then + RG_ARGS+=("$OPT_CASE_SENSITIVITY") +fi + if "$OPT_FOLLOW"; then RG_ARGS+=("--follow") fi