is_git_repo and rvm stuff

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2017-11-09 15:26:42 +03:00
parent a822b302aa
commit f9fdcd4b16
4 changed files with 19 additions and 5 deletions

View File

@@ -44,6 +44,20 @@ precmd.svn() {
fi
}
precmd.is_git_repo() {
declare _pwd=$PWD
while [[ -n $_pwd ]]; do
if [[ -r "$_pwd/.git/HEAD" ]]; then
return 0
else
_pwd=${pwd%/*}
fi
done
return 1
}
precmd.git() {
declare git_unstaged git_untracked git_status_short git_status_colour git_prompt_msg
@@ -51,7 +65,7 @@ precmd.git() {
return 0
fi
if git rev-parse --git-dir &>/dev/null; then
if precmd.is_git_repo; then
git_current_branch=$(git rev-parse --abbrev-ref HEAD)
while IFS= read -r line; do