Skip to content

Instantly share code, notes, and snippets.

@fbartho
Forked from johngraham262/openx_bash_for_ios
Last active October 30, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbartho/147ce382559d7000e82f0546a62c8f5e to your computer and use it in GitHub Desktop.
Save fbartho/147ce382559d7000e82f0546a62c8f5e to your computer and use it in GitHub Desktop.
A simple bash script that will open a `.xcworkspace` if it exists in the current directory, otherwise a `.xcodeproj` if it exists, otherwise nothing. It will print the name of the file that is being opened. When using Cocoapods with iOS apps, a second file is created with the `MyProject.xcworkspace` name, alongside the `MyProject.xcproject` file…
# Add the following lines of code to your `~/.bash_profile`,
# and then run `source ~/.bash_profile` to be able to execute
# this from the command line.
# Originally from: https://gist.github.com/johngraham262/6546595
# Spaces-in-filenames from: https://gist.github.com/johngraham262/6546595#gistcomment-1823783
openx() {
fileToOpen='';
find . -maxdepth 1 -name *.xcworkspace -print0 | while IFS= read -r -d '' file; do
fileToOpen=$file
done
if [ -n "$fileToOpen" ]
then
echo $fileToOpen
xed $fileToOpen
else
find . -maxdepth 1 -name *.xcodeproj -print0 | while IFS= read -r -d '' file; do
fileToOpen=$file
done
if [ -n "$fileToOpen" ]
then
echo $fileToOpen
xed $fileToOpen
else
echo "No xcode files to open."
fi
fi
}
# Feel free to alias this to smaller!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment