]> gitweb.fluxo.info Git - shellprompt.git/commitdiff
Avoid git pw3nage
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 18 Mar 2017 17:14:35 +0000 (14:14 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 18 Mar 2017 17:14:35 +0000 (14:14 -0300)
files/prompt

index e580dedbf175d62bfa28548e36227459185dff76..02f0d83371b314bdcb36e168b333f15be3973090 100755 (executable)
@@ -35,8 +35,17 @@ command_prompt() {
   local base_prompt="${status_color}${exit_status}${COLOR_NONE} ${COLOR_CYAN}\D{%Y%m%d %H:%M:%S}${COLOR_NONE} ${COLOR_CYAN}${debian_chroot:+($debian_chroot) }${COLOR_NONE}${COLOR_YELLOW}\u@\h${COLOR_NONE}:${COLOR_CYAN}\w"
 
   # Check if completion is available
-  if type __git_ps1 &> /dev/null; then
-    PS1="${base_prompt}$(__git_ps1 " (%s)")${COLOR_NONE} \\$ "
+  # See https://github.com/njhartwell/pw3nage
+  #if type __git_ps1 &> /dev/null; then
+  if [ -x "/usr/bin/git" ]; then
+    #PS1="${base_prompt}$(__git_ps1 " (%s)")${COLOR_NONE} \\$ "
+    branch="`/usr/bin/git branch 2> /dev/null | grep '^* ' | sed -e 's/\* //' -e 's/ $//'`"
+
+    if [ ! -z "$branch" ]; then
+      branch=" (${branch//[^a-z0-9\/]/-})"
+    fi
+
+    PS1="${base_prompt}$branch${COLOR_NONE} \\$ "
   else
     PS1="${base_prompt}${COLOR_NONE} \\$ "
   fi