Skip to content

Instantly share code, notes, and snippets.

@TheCodedSelf
Last active September 8, 2016 05:19
Show Gist options
  • Save TheCodedSelf/cb4985f57f549629f95d791d801e5fdc to your computer and use it in GitHub Desktop.
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
#!/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