From 356933675aaa9113c199d9699fea8923b3ef2260 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 24 Aug 2016 11:50:24 +1200 Subject: Rename gress() to gore() Important work going on here, folks --- sh/shrc.d/gore.sh | 21 +++++++++++++++++++++ sh/shrc.d/gress.sh | 22 ---------------------- 2 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 sh/shrc.d/gore.sh delete mode 100644 sh/shrc.d/gress.sh (limited to 'sh') diff --git a/sh/shrc.d/gore.sh b/sh/shrc.d/gore.sh new file mode 100644 index 00000000..1df637bb --- /dev/null +++ b/sh/shrc.d/gore.sh @@ -0,0 +1,21 @@ +# Pipe grep(1) output through PAGER; mostly to preserve coloring interactively +# through less(1), but it'll work fine with plain grep(1) and more(1) +gore() { + + # Add --color=always if the terminal has at least 8 colors; we have to add + # "always" to coax grep(1) into emitting colors even though it can tell its + # stdout isn't a terminal but a pager + [ -e "$HOME"/.cache/grep/color ] && + [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && + set -- --color=always "$@" + + # Run whatever `grep` gives us; it might be our function wrapper; that's OK + grep "$@" | + + # Run the appropriate pager; if it's less(1), we can tack on -R (though my + # ~/.lesskey does this anyway) + case $PAGER in + less) "$PAGER" -R ;; + *) "$PAGER" ;; + esac +} diff --git a/sh/shrc.d/gress.sh b/sh/shrc.d/gress.sh deleted file mode 100644 index 483198b3..00000000 --- a/sh/shrc.d/gress.sh +++ /dev/null @@ -1,22 +0,0 @@ -# Pipe grep(1) output through PAGER; mostly to preserve grep colouring -# interactively through less(1), but it'll work fine with plain grep(1) and -# more(1) -gress() { - - # Add --color=always if the terminal has at least 8 colors; we have to add - # "always" to coax grep(1) into emitting colors even though it can tell its - # stdout isn't a terminal but a pager - [ -e "$HOME"/.cache/grep/color ] && - [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && - set -- --color=always "$@" - - # Run grep; it might be our function wrapper; that's OK - grep "$@" | - - # Run the appropriate pager; if it's less(1), we can tack on -R (though my - # ~/.lesskey does this anyway) - case $PAGER in - less) "$PAGER" -R ;; - *) "$PAGER" ;; - esac -} -- cgit v1.2.3