From 73e7e7e33e8f799be63f2d1198b1c420f0b10d4f Mon Sep 17 00:00:00 2001
From: Chris Coley <chris@codingallnight.com>
Date: Thu, 21 Jun 2018 14:26:59 -0700
Subject: [PATCH] Improving the integration with git

---
 bashrc               | 10 ++++++++--
 bashrc.local.example |  9 +++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/bashrc b/bashrc
index 50204fd..e9664c6 100644
--- a/bashrc
+++ b/bashrc
@@ -51,10 +51,16 @@ fi
 
 if [ "$color_prompt" = yes ] && [ "`id -u`" -eq 0 ]; then
     # Red prompt for root
-    PS1='${debian_chroot:+($debian_chroot)}\h:\[\033[31m\][\w]\[\033[00m\] \$ '
+#    PS1='${debian_chroot:+($debian_chroot)}\h:\[\033[31m\][\w]\[\033[00m\] \$ '
+    PS1_PRE='${debian_chroot:+($debian_chroot)}\h:\[\033[31m\][\w]\[\033[00m\]'
+    PS1_POST=' \$ '
+    PS1="$PS1_PRE$PS1_POST"
 else
     # Default prompt for everyone else
-    PS1='${debian_chroot:+($debian_chroot)}\h:\[\033[38;5;25m\][\w]\[\033[00m\] \$ '
+#    PS1='${debian_chroot:+($debian_chroot)}\h:\[\033[38;5;25m\][\w]\[\033[00m\] \$ '
+    PS1_PRE='${debian_chroot:+($debian_chroot)}\h:\[\033[38;5;25m\][\w]\[\033[00m\]'
+    PS1_POST=' \$ '
+    PS1="$PS1_PRE$PS1_POST"
 fi
 unset color_prompt force_color_prompt
 
diff --git a/bashrc.local.example b/bashrc.local.example
index 125d26e..2536712 100644
--- a/bashrc.local.example
+++ b/bashrc.local.example
@@ -12,7 +12,12 @@ if [ -f ~/.git-prompt.sh ]; then
     source ~/.git-prompt.sh
 fi
 
-PROMPT_COMMAND='__git_ps1 "${debian_chroot:+($debian_chroot)}\h:\[\033[38;5;25m\][\w]\[\033[00m\]" " \$ " " {%s}"'
+if [ -z ${PS1_PRE+x} ] && [ -z ${PS1_POST+x} ]; then
+    PS1_PRE='${debian_chroot:+($debian_chroot)}\h:\[\033[38;5;25m\][\w]\[\033[00m\]'
+    PS1_POST=' \$ '
+fi
+
+PROMPT_COMMAND='__git_ps1 "$PS1_PRE" "$PS1_POST" " {%s}"'
 
 if [ -d $HOME/.virtualenvs ] && [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
     # If virtualenv was installed with python3, then we can assume that
@@ -52,5 +57,5 @@ if [ -d $HOME/.virtualenvs ] && [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
             fi
         fi
     }
-    PROMPT_COMMAND='__git_ps1 "${debian_chroot:+($debian_chroot)}$(add_venv_info)\h:\[\033[38;5;25m\][\w]\[\033[00m\]" " \$ " " {%s}"'
+    PROMPT_COMMAND='__git_ps1 "$PS1_PRE $(add_venv_info)" "$PS1_POST" " {%s}"'
 fi
-- 
GitLab