aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-18 10:21:43 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-18 10:21:43 +1200
commitb84fd8bdafcbc56dfe480b6b7946a8911cc5ead6 (patch)
tree74d9dcce65c585441b12be755c27929949de3e59 /bash/bashrc.d
parentReplace Bashism "hash" with POSIX sh "command" (diff)
downloaddotfiles-b84fd8bdafcbc56dfe480b6b7946a8911cc5ead6.tar.gz
dotfiles-b84fd8bdafcbc56dfe480b6b7946a8911cc5ead6.zip
Port grep() and ls() to POSIX sh
Check capabilities of wrapped programs at runtime, not declaration time. Also do away with the silly GREP_COLORS and GREP_OPTS variables. Considering doing the same with LS_COLORS.
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/grep.bash35
-rw-r--r--bash/bashrc.d/ls.bash20
2 files changed, 0 insertions, 55 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash
deleted file mode 100644
index 624baf30..00000000
--- a/bash/bashrc.d/grep.bash
+++ /dev/null
@@ -1,35 +0,0 @@
-# Our ~/.profile should already have made a directory with the supported
-# options for us
-[[ -d $HOME/.cache/grep ]] || return
-
-# Store whether we have colors in a variable
-declare -i colors
-colors=$( {
- tput Co || tput colors
-} 2>/dev/null )
-
-# Use GREPOPTS to add some useful options to grep(1) calls if applicable; we
-# use a function wrapper to do this, rather than GREP_OPTIONS as we don't want
-# to change grep(1)'s actual behaviour inside scripts
-declare -a GREPOPTS
-GREPOPTS=()
-if ((colors >= 8)) && [[ -n $GREP_COLORS ]] ; then
- GREPOPTS[${#GREPOPTS[@]}]='--color=auto'
-fi
-if [[ -e $HOME/.cache/grep/binary-files ]] ; then
- GREPOPTS[${#GREPOPTS[@]}]='--binary-files=without-match'
-fi
-if [[ -e $HOME/.cache/grep/exclude ]] ; then
- GREPOPTS[${#GREPOPTS[@]}]='--exclude={.gitignore,.gitmodules}'
-fi
-if [[ -e $HOME/.cache/grep/exclude-dir ]] ; then
- GREPOPTS[${#GREPOPTS[@]}]='--exclude-dir={.cvs,.git,.hg,.svn}'
-fi
-
-# Done, unset color var
-unset -v colors
-
-# Define function proper
-grep() {
- command grep "${GREPOPTS[@]}" "$@"
-}
diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash
deleted file mode 100644
index 4b647163..00000000
--- a/bash/bashrc.d/ls.bash
+++ /dev/null
@@ -1,20 +0,0 @@
-# Store whether we have colors in a variable
-declare -i colors
-colors=$( {
- tput Co || tput colors
-} 2>/dev/null )
-
-# Use LSOPTS to add some useful options to ls(1) calls if applicable; we use a
-# function wrapper to do this
-declare -a LSOPTS
-if [[ -n $LS_COLORS ]] && ((colors >= 8)) ; then
- LSOPTS[${#LSOPTS[@]}]='--color=auto'
-fi
-
-# Done, unset helper var
-unset -v colors
-
-# Define function proper
-ls() {
- command ls "${LSOPTS[@]}" "$@"
-}