Skip to content

Instantly share code, notes, and snippets.

@yiyuanlu
Forked from xhan/.profile
Created July 4, 2012 07:00
Show Gist options
  • Save yiyuanlu/3045806 to your computer and use it in GitHub Desktop.
Save yiyuanlu/3045806 to your computer and use it in GitHub Desktop.
cd to current Xcode's project folder in Terminal
function cdxcode()
{
path="`osascript ~/Codes/scripts/cdxcode.scpt 2>/dev/null`"
if [ -n "$path" ]; then
echo "cd to $path"
cd "$path"
else
echo "no Xcode Project finded"
fi
}
to split(aString, delimiter)
set oldastid to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set pieces to aString's text items
set AppleScript's text item delimiters to oldastid
return pieces
end split
tell application id "com.apple.dt.Xcode"
set my_work_space to active workspace document
-- set my_projects to projects of my_work_space
-- set my_project to item 1 of my_projects
set my_windows to windows
set my_window to item 1 of my_windows
set window_name to name of my_window
tell me
set ppp to split(window_name, ".xcodeproj")
end tell
set projname to item 1 of ppp
tell project projname
set xxxxxx to project directory
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment