diff options
-rw-r--r-- | config.default | 3 | ||||
-rw-r--r-- | contrib/rfgrep/Makefile | 6 | ||||
-rwxr-xr-x | contrib/rfgrep/rfgrep | 23 |
3 files changed, 31 insertions, 1 deletions
diff --git a/config.default b/config.default index b1f5a8e..28e98e7 100644 --- a/config.default +++ b/config.default @@ -1,4 +1,3 @@ -# vim: ft=config # this is a default config file for rf # the options as presented here should match the default behaviour # of rf and should give you an overview of what is configurable @@ -27,3 +26,5 @@ limit = 0 # rf {pattern} || fallback # # unmatched error + +# vim: ft=config diff --git a/contrib/rfgrep/Makefile b/contrib/rfgrep/Makefile new file mode 100644 index 0000000..1468fec --- /dev/null +++ b/contrib/rfgrep/Makefile @@ -0,0 +1,6 @@ +BIN = rfgrep +PREFIX = /usr/local + +install: + mkdir -p $(DESTDIR)$(PREFIX)/bin + install -m755 $(BIN) $(DESTDIR)$(PREFIX)/bin/ diff --git a/contrib/rfgrep/rfgrep b/contrib/rfgrep/rfgrep new file mode 100755 index 0000000..d1f262e --- /dev/null +++ b/contrib/rfgrep/rfgrep @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +files= +edit= + +EDITOR=${EDITOR:-vim} + +while getopts 'ef' opt; do + case $opt in + e) edit=1; shift ;; + f) files=1; shift ;; + esac +done + +if [ "$files" ]; then + rf '*' | xargs grep -Ir "$1" | awk -F':' '{print $1}' | sort | uniq +elif [ "$edit" ]; then + $EDITOR $(rf '*' | xargs grep -Ir "$1" | awk -F':' '{print $1}' | sort | uniq) +else + rf '*' | xargs grep -Ir "$1" +fi |