findex (335B)
1 #!/usr/bin/env bash 2 3 if [ -z "$1" ]; then 4 printf 'usage: findex <rg query>\n' 5 exit 1 6 fi 7 8 # cd to project root 9 cd $(git rev-parse --show-toplevel) 10 11 rg "$1" | 12 grep -E '^[^:]+:.*$' | 13 cut -d: -f2- | 14 sort | 15 uniq -c | 16 sort -nr | 17 sed 's,^[[:space:]]*,,g;s,\(^[[:digit:]]\+\) ,\1\t,g' | 18 cut -d $'\t' --output-delimiter=$'\t' -f2- | 19 head -n5