Skip to content

Commit

Permalink
Match xcodeproj file if no xcworkspace file is found
Browse files Browse the repository at this point in the history
  • Loading branch information
macecchi committed May 5, 2016
1 parent 75d163c commit f31701a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions xcopen
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
#!/bin/bash
EXT='xcworkspace'

DIR=${1:-.} # DIR is either the first argument or the current directory
# DIR is either the first argument or the current directory
DIR=${1:-.}

shopt -s nullglob

found=0

# Try to open the first xcworkspace file found
EXT='xcworkspace'
for i in ${DIR}/*.${EXT}; do
open -a Xcode "$i"
found=1
break
done
[ $found -eq 0 ] && echo "No Xcode workspace found"

shopt -u nullglob
# If nothing was found, try to open the first xcodeproj file found
if [ $found -eq 0 ]
then
EXT='xcodeproj'
for i in ${DIR}/*.${EXT}; do
open -a Xcode "$i"
found=1
break
done
fi

# Print message if nothing was found
[ $found -eq 0 ] && echo "No xcworkspace/xcodeproj file found in the specified directory."

shopt -u nullglob

0 comments on commit f31701a

Please sign in to comment.