-
-
Save 3lvis/9719935 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
function openWorkspaceOrProjectWithApp() | |
{ | |
if [[ -z "$1" || "$#" -ne 2 ]]; then | |
echo -e "Nothing found\n" | |
return | |
fi | |
IDEFileName=${2##*/} | |
filename=${1##*/} | |
echo -e "\nOpening $filename with $IDEFileName\n" | |
# open "$1" -a "$2" | |
} | |
function selectWorkspaceOrProject() | |
{ | |
count=$# | |
file="" | |
if [[ $count -eq 1 ]]; then | |
file=$1 | |
elif [[ $count > 1 ]]; then | |
echo "" | |
for (( i = 0; i < $count; i++ )); do | |
index=`expr $i + 1` | |
eval "filename=\${$index}" | |
echo -e "\t" "[$index]" "$filename" | |
done | |
printf "\nSelect the file to open: " | |
read -s -n 1 result | |
if [[ ! -z $result ]]; then | |
eval "file=\${$result}" | |
fi | |
fi | |
} | |
function openWorkspaceOrProject() | |
{ | |
shopt -s nullglob | |
workspaces=(*.xcworkspace) | |
count=${#workspaces[@]} | |
if [[ count -ne 0 ]]; then | |
selectWorkspaceOrProject "${workspaces[@]}" | |
openWorkspaceOrProjectWithApp "$file" $1 | |
else | |
shopt -s nullglob | |
projects=(*.xcodeproj) | |
count=${#projects[@]} | |
selectWorkspaceOrProject "${projects[@]}" | |
openWorkspaceOrProjectWithApp "$file" $1 | |
fi | |
} | |
function opena | |
{ | |
IDEPath="/Applications/AppCode.app" | |
openWorkspaceOrProject "$IDEPath" | |
} | |
function openx | |
{ | |
IDEPath="/Applications/Xcode.app" | |
openWorkspaceOrProject "$IDEPath" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment