#!/bin/bash
# blinker-tool
# description: Find where a name is used in the project: every line that
# description: mentions it as a whole word, with its file and line number.
# arg name string: The name to look for.
if command -v rg >/dev/null; then
out=$(rg --line-number --no-heading --word-regexp --fixed-strings --glob '!.git' -- "$1" . | head -200)
else
out=$(grep -rnwF --exclude-dir=.git -- "$1" . | head -200)
fi
if [ -z "$out" ]; then
echo "No uses of $1 found."
else
printf '%s\n' "$out"
fi
|