-
-
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…
This file contains 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
# 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