bin/herefind
#!/bin/bash
# This script runs git find (see gitconfig) through all git repositories
# directly underneath my current directory
set -euo pipefail
IFS=$'\n\t'
if [[ -z "${1+x}" ]] || [[ "$1" == "-h" ]]; then
echo "Runs a git find operation under each git repository underneath the current pwd"
exit
fi
yellow='\e[1;33m'
reset='\e[0m'
for f in ./*; do
if [ ! -d "$f/.git" ]; then
continue
fi
result="$(git -C "$f" find "$@" || true)"
if [[ -n "$result" ]]; then
echo -e "${yellow}$f${reset}"
tput rmam # Disable line wrapping in terminal
echo "$result"
tput smam # Reenable line wrapping in terminal
fi
done