Last active
December 23, 2015 18:39
-
-
Save alikaragoz/6676778 to your computer and use it in GitHub Desktop.
Find and open the first xcworkspace or xcodeproj in a folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xc () { | |
workspaces=(`ls -d1 *.(xcworkspace|xcodeproj) | sed -e "s/\///g"`) &> /dev/null | |
filenames=(`ls -d1 *.(xcworkspace|xcodeproj) | sed -e "s/\..*$//g"`) &> /dev/null | |
if [[ ${#workspaces} = 0 ]] | |
then | |
echo "No Xcode projects or workspaces were found." | |
return | |
fi | |
if [[ ${#workspaces} = 1 ]] | |
then | |
`open $workspaces[1] -a /Applications/Xcode.app` | |
return | |
fi | |
if [[ ${#workspaces} = 2 ]] | |
then | |
if [[ $filenames[1] = $filenames[2] ]] | |
then | |
`open $workspaces[2] -a /Applications/Xcode.app` | |
return | |
fi | |
fi | |
counter=1 | |
echo "Multiple choice currently isn't enabled. Available workspaces:" | |
for workspace in workspaces | |
do | |
echo "$counter. $workspace" | |
set counter += 1 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment