Skip to content

Instantly share code, notes, and snippets.

@tzarskyz
Forked from rbsgn/gist:5089314
Created June 29, 2013 17:22
Show Gist options
  • Save tzarskyz/5891932 to your computer and use it in GitHub Desktop.
Save tzarskyz/5891932 to your computer and use it in GitHub Desktop.
#!/bin/bash
find_project_or_workspace() {
MASK=$1
ALL_PROJECTS_OR_WORKSPACES=`/bin/ls -1 -d $MASK 2>/dev/null`
FILE_TO_OPEN=''
if [ z"${ALL_PROJECTS_OR_WORKSPACES}" != z ] ; then
for i in ${ALL_PROJECTS_OR_WORKSPACES} ; do
if [ z"${PROJECT}" == z ] ; then
PROJECT_OR_WORKSPACE=${i}
else
break
fi
done
if [ z"${PROJECT_OR_WORKSPACE}" != z ] ; then
FILE_TO_OPEN=`basename "${PROJECT_OR_WORKSPACE}"`
fi
fi
echo $FILE_TO_OPEN
}
find_project() {
echo $(find_project_or_workspace '*.xcodeproj')
}
find_workspace() {
echo $(find_project_or_workspace '*.xcworkspace')
}
THING_TO_OPEN=$(find_workspace)
if [ z"${THING_TO_OPEN}" == z ]; then
THING_TO_OPEN=$(find_project)
fi
if [ z"${THING_TO_OPEN}" == z ]; then
echo "Can't find single workspace or project file in current directory, exiting..."
exit 1
fi
open "${THING_TO_OPEN}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment