Selaa lähdekoodia

curgitb : return the current git branch

Jovian (Darkside) 6 vuotta sitten
vanhempi
commit
436573a54f
1 muutettua tiedostoa jossa 5 lisäystä ja 7 poistoa
  1. 5 7
      Useful/curgitb

+ 5 - 7
Useful/curgitb

@@ -1,9 +1,7 @@
 #!/bin/bash
-current_branch=`git branch | grep \* | cut -d ' ' -f2`
-if [ $? -eq 0 ]
+current_branch=`git branch 2>&1`
+if [ "$current_branch" != 'fatal: not a git repository (or any of the parent directories): .git' ]
 then
-	echo 'Success'
-else
-	echo 'Failed'
-fi
-echo $current_branch
+	current_branch=`echo "$current_branch" | grep \* | cut -d ' ' -f2`
+	echo "($current_branch)"
+fi