aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-19 16:09:19 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-19 16:09:19 +1200
commitf0353dd63d2d75d808a602c3029588b5e9b34d6c (patch)
treebd0e57408b2821b6297e7b1822a74df763379f60 /sh
parentKid gloves only needed for GCC_COLORS (diff)
downloaddotfiles-f0353dd63d2d75d808a602c3029588b5e9b34d6c.tar.gz
dotfiles-f0353dd63d2d75d808a602c3029588b5e9b34d6c.zip
Need to actually make LS/GREP_COLORS conditional
Diffstat (limited to 'sh')
-rw-r--r--sh/profile.d/grep.sh12
-rw-r--r--sh/profile.d/ls.sh25
2 files changed, 26 insertions, 11 deletions
diff --git a/sh/profile.d/grep.sh b/sh/profile.d/grep.sh
index d8b113c3..444adb16 100644
--- a/sh/profile.d/grep.sh
+++ b/sh/profile.d/grep.sh
@@ -1,10 +1,14 @@
-# Define and store appropriate colors for grep(1)
-GREP_COLORS='ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36'
-export GREP_COLORS
-
# Store grep(1)'s --help output in a variable
grep_help=$(grep --help 2>/dev/null)
+# Use GREP_COLORS to add color output to grep(1) if option available
+case $grep_help in
+ *--color*)
+ GREP_COLORS='ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36'
+ export GREP_COLORS
+ ;;
+esac
+
# Use GREP_OPTIONS to add some useful options to grep(1) calls if applicable
GREP_OPTIONS=
case $grep_help in
diff --git a/sh/profile.d/ls.sh b/sh/profile.d/ls.sh
index 7757f3fe..a477c510 100644
--- a/sh/profile.d/ls.sh
+++ b/sh/profile.d/ls.sh
@@ -1,8 +1,19 @@
-if command -v dircolors >/dev/null 2>&1 ; then
- if [ -r "$HOME"/.dircolors ] ; then
- eval "$(dircolors --sh -- "$HOME"/.dircolors)"
- else
- eval "$(dircolors --sh)"
- fi
-fi
+# Store ls(1)'s --help output in a variable
+ls_help=$(ls --help 2>/dev/null)
+
+# Run dircolors(1) to export LS_COLORS if available and appropriate
+case $ls_help in
+ *--color*)
+ if command -v dircolors >/dev/null 2>&1 ; then
+ if [ -r "$HOME"/.dircolors ] ; then
+ eval "$(dircolors --sh -- "$HOME"/.dircolors)"
+ else
+ eval "$(dircolors --sh)"
+ fi
+ fi
+ ;;
+esac
+
+# We're done parsing ls(1)'s --help output now
+unset -v ls_help