Skip to content

Instantly share code, notes, and snippets.

@xhan
Created May 24, 2012 06:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xhan/2779853 to your computer and use it in GitHub Desktop.
Save xhan/2779853 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
@lihex
Copy link

lihex commented May 28, 2012

我有一个towk的shell函数,也是用来跳转到工作目录的,真是异曲同工啊!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment