helm/bin/project-root

12 lines
253 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
local dir="${PWD%/*}"
while [[ ! -d "$dir/.git" && ! -d "$dir/.hg" && ! -d "$dir/.svn" && ! -f "$dir/.project" ]]; do
dir="${dir%/*}"
if [[ -z "$dir" ]]; then
echo -n "$PWD"
return
fi
done
echo -n "$dir"