From e84ea6f307bd12783d4d0ae721ecaad1b6005b30 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Sun, 26 Nov 2023 10:04:34 -0600 Subject: [PATCH] .bashrc: Only set GREP_COLOR env-var on BSD-type platforms Older grep versions used the GREP_COLOR env-var for colorized output configuration. Newer GNU grep versions use the GREP_COLORS env-var, which supports additional colorize options. GNU grep 3.8+ will now log a warning message if the GREP_COLOR env-var is set, warning that env-var is deprecated. But BSD grep still relies on GREP_COLOR. Conditionalize the setting of GREP_COLOR vs GREP_COLORS based on OS-type [e.g. GNU grep vs BSD grep]. --- .bashrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.bashrc b/.bashrc index c0ea16d..510102b 100644 --- a/.bashrc +++ b/.bashrc @@ -337,6 +337,14 @@ test -n "$LS_COMMON" && # setup color grep output if available if [ -n "$COLORS" ]; then + case "$UNAME" in + "Darwin") + export GREP_COLOR='1;32' # BSD grep + ;; + *) + export GREP_COLORS='fn=36:ln=33:ms=1;32' # GNU grep + ;; + esac case "$UNAME" in "SunOS") test -x /usr/gnu/bin/grep && alias grep="/usr/gnu/bin/grep --color=always" @@ -346,10 +354,6 @@ if [ -n "$COLORS" ]; then alias grep="command grep --color=always" ;; esac - # older versions of grep only support a singular highlight color - export GREP_COLOR='1;32' - # newer versions of grep have more flexible color configuration - export GREP_COLORS='fn=36:ln=33:ms=1;32' fi # --------------------------------------------------------------------------- -- 2.45.2