#!/bin/sh DEPTH=${1:-4} set -eu ls_r() { local count="$1" base="$2" local x= d= shift 2 count=$(($count - 1)) [ $count -gt 0 ] || return [ ! -e "$base/.git" ] || echo "${base#./}" for d in "$base"/*; do if [ -d "$d" ]; then ls_r $count "$d" & fi done wait } ls_r "$DEPTH" .