rwxrob-dot/scripts/pdgit
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

15 lines
284 B
Bash
Executable File

#!/bin/sh
## Prints the parent (or grandparent) directory that contains the .git
## directory (or file in the case of worktrees). Assumes $PWD if no
## argument provided.
pdgit() {
dir=${1:-$PWD}
pdir=$(pdhas .git)
test -z "$pdir" && return 1
echo "${pdir%/.git}"
}
pdgit "$@"