cbdad588e65f4205fcdc4e34e97b04fa7fdb5457

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Use zsh globbing instead of ls + grep in xc function

Uses zsh arrays and globbing to find .xcworkspace and .xcodeproj files.

Diff

 1diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
 2index 1d1205b80887400804f6a45f8d96c17a71507ef4..4aa6bfc9b12431187b7d4d079fefa7129e934c8a 100644
 3--- a/plugins/xcode/xcode.plugin.zsh
 4+++ b/plugins/xcode/xcode.plugin.zsh
 5@@ -1,12 +1,12 @@
 6 #xc function courtesy of http://gist.github.com/subdigital/5420709
 7 function xc {
 8-  xcode_proj=`ls | grep "\.xc" | sort -r | head -1`
 9-  if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
10-  then
11+  local xcode_proj
12+  xcode_proj=(*.{xcworkspace,xcodeproj}(N))
13+  if [[ ${#xcode_proj} -eq 0 ]]; then
14     echo "No xcworkspace/xcodeproj file found in the current directory."
15   else
16-    echo "Found $xcode_proj" 
17-    open "$xcode_proj" 
18+    echo "Found ${xcode_proj[1]}"
19+    open "${xcode_proj[1]}"
20   fi
21 }
22