Last active
September 8, 2016 05:19
-
-
Save TheCodedSelf/cb4985f57f549629f95d791d801e5fdc to your computer and use it in GitHub Desktop.
Bash script that opens any xcworkspace or xcodeproj found in the current directory in Xcode
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
#!/bin/bash | |
# | |
# Opens any xcworkspace or xcodeproj found in the current directory in Xcode. | |
# | |
openfile () ( | |
file="$1" | |
echo "Opening $file"; | |
open $file; | |
) | |
all_files_of_type () ( | |
file="$1" | |
local allfiles="$(find . -maxdepth 1 -type d | grep "\.$file$")" | |
echo $allfiles | |
) | |
argumentDir=$1 | |
if [[ -d "$argumentDir" ]]; then | |
cd $argumentDir | |
fi | |
files="$(all_files_of_type xcworkspace)" | |
for file in $files; do | |
openfile $file | |
exit | |
done | |
files="$(all_files_of_type xcodeproj)" | |
for file in $files; do | |
openfile $file | |
exit | |
done | |
echo "Could not fine a .xcworkspace or .xcproj file to open." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment