Browse code

Merge pull request #717 from blueyed/github-plugin-working-hub

github plugin: only alias git=hub if `hub --version` works.

Robby Russell authored on 22/01/2012 at 21:11:08
Showing 1 changed files
... ...
@@ -1,7 +1,17 @@
1 1
 # Setup hub function for git, if it is available; http://github.com/defunkt/hub
2 2
 if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
3 3
     # eval `hub alias -s zsh`
4
-    function git(){hub "$@"}
4
+    function git(){
5
+        if ! (( $+_has_working_hub  )); then
6
+            hub --version &> /dev/null
7
+            _has_working_hub=$(($? == 0))
8
+        fi
9
+        if (( $_has_working_hub )) ; then
10
+            hub "$@"
11
+        else
12
+            command git "$@"
13
+        fi
14
+    }
5 15
 fi
6 16
 
7 17
 # Functions #################################################################