You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
284 B
Bash

#!/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 "$@"