Ensure that the directory is within a git repository
If not, return early in `git_prompt` info. Fixes #3
This commit is contained in:
parent
d942a47ef5
commit
aa11d28b61
|
@ -1,3 +1,11 @@
|
||||||
|
git_is_repo() {
|
||||||
|
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
git_current_branch() {
|
git_current_branch() {
|
||||||
echo $(git rev-parse --abbrev-ref HEAD)
|
echo $(git rev-parse --abbrev-ref HEAD)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +19,8 @@ git_repo_is_dirty() {
|
||||||
}
|
}
|
||||||
|
|
||||||
git_prompt_info() {
|
git_prompt_info() {
|
||||||
|
! git_is_repo || return
|
||||||
|
|
||||||
current_branch=$(git_current_branch 2> /dev/null)
|
current_branch=$(git_current_branch 2> /dev/null)
|
||||||
suffix=''
|
suffix=''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue