diff options
Diffstat (limited to 'contrib/rfgrep')
-rw-r--r-- | contrib/rfgrep/Makefile | 6 | ||||
-rwxr-xr-x | contrib/rfgrep/rfgrep | 23 |
2 files changed, 29 insertions, 0 deletions
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 |