summaryrefslogtreecommitdiff
path: root/rc/bin/g
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-02-05 00:40:45 +0000
committerOri Bernstein <ori@eigenstate.org>2022-02-05 00:40:45 +0000
commit1290c534bef72b282b4c562b95a4b2be8237e3b0 (patch)
tree56f783d18d3e37173a81214b5f19673b6667d185 /rc/bin/g
parent251c3cfd610abd169676852d301a2aa1267c0e57 (diff)
g: show all file names when grepping
When grep gets a single file argument, it does not show the file name. This makes seeing the file name in the output of 'g' difficult. Pass a spare /dev/null to each invocation of g, in order to force it to show the file name.
Diffstat (limited to 'rc/bin/g')
-rwxr-xr-xrc/bin/g3
1 files changed, 2 insertions, 1 deletions
diff --git a/rc/bin/g b/rc/bin/g
index 5f55715a0..aa57d17e8 100755
--- a/rc/bin/g
+++ b/rc/bin/g
@@ -23,6 +23,7 @@ shift
suffixes='\.([bcChlmsy]|asm|awk|cc|cgi|cpp|cs|go|goc|hs|java|lua|lx|mk|ml|mli|ms|myr|pl|py|rc|sh|tex|xy)$'
fullnames='(^|/)mkfile$'
+repodirs='(^|/)(.git|.hg)($|/)'
switch($#*){
case 0
walk -f $recurse | grep -e $fullnames -e $suffixes >[2]/dev/null
@@ -34,4 +35,4 @@ case *
if not
echo $f
}
-} | xargs grep -n $flags -- $pattern
+} | grep -v $repodirs | xargs grep -n $flags -- $pattern /dev/null