From 1c5aba7f1b2a53cdcaf896df118f3c7b42c0251c Mon Sep 17 00:00:00 2001 From: Rory Bradford Date: Sun, 30 Aug 2020 12:15:39 +0100 Subject: Add rfgrep contrib script Signed-off-by: Rory Bradford --- contrib/rfgrep/Makefile | 6 ++++++ contrib/rfgrep/rfgrep | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 contrib/rfgrep/Makefile create mode 100755 contrib/rfgrep/rfgrep (limited to 'contrib/rfgrep') 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 -- cgit 1.4.1-2-gfad0