#!/bin/bash repoRoot=$(git rev-parse --show-toplevel) listFilesToSubstitute=$(find -name *.gitsubstitute) listStaticPathFiles=$(git grep -lr --untracked $repoRoot) listStagedFiles=$(git diff --staged --name-only) staticPathSubstitution="\${REPO_ROOT}" for entryFileToSubstitute in $listFilesToSubstitute; do fullPath="${repoRoot}/${entryFileToSubstitute}" fullPathSubstitute="${repoRoot}/${entryFileToSubstitute%.gitsubstitute}" fileContent=$(<$fullPath) echo "${fileContent//${staticPathSubstitution}/${repoRoot}}" > "${fullPathSubstitute}" done