From ff7575ccdcc556e5ffb591bff85b8b7ac4e2f985 Mon Sep 17 00:00:00 2001 From: Martin Goldhahn Date: Sun, 4 Aug 2013 19:06:28 +0200 Subject: [PATCH] apply git prompt only on directories belonging to a git repository --- .gitignore | 2 ++ gitprompt.sh | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7683df --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.bak diff --git a/gitprompt.sh b/gitprompt.sh index f9e5c69..cb7254d 100644 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -98,6 +98,8 @@ function setGitPrompt() { local __GIT_STATUS_CMD git_prompt_config + + EMPTY_PROMPT=${OLD_GITPROMPT} local repo=`git rev-parse --show-toplevel 2> /dev/null` if [[ ! -e "${repo}" ]]; then @@ -167,6 +169,10 @@ function setGitPrompt() { fi } +if [ -z "$OLD_GITPROMPT" ]; then + OLD_GITPROMPT=$PS1 +fi + if [ -z "$PROMPT_COMMAND" ]; then PROMPT_COMMAND=setGitPrompt else