Skip to content

Instantly share code, notes, and snippets.

@pwc3
Created March 30, 2014 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwc3/9867443 to your computer and use it in GitHub Desktop.
Save pwc3/9867443 to your computer and use it in GitHub Desktop.
tell application "Xcode"
set _workspace to active workspace document
set _workspaceFile to file of _workspace
end tell
tell application "Finder"
set _posixTargetPath to quoted form of POSIX path of _workspaceFile
end tell
tell application "Xcode"
set _curBranch to do shell script "cd " & _posixTargetPath & "; cd ../../; git rev-parse --abbrev-ref HEAD"
set _mods to do shell script "cd " & _posixTargetPath & "; cd ../../; git diff --no-ext-diff --quiet --exit-code || echo 'modified'"
set _adds to do shell script "cd " & _posixTargetPath & "; cd ../../; git diff-index --cached --quiet HEAD -- || echo 'added'"
if _mods is equal to "" and _adds is equal to "" then
set _status to "Working directory is clean"
else if _mods is not equal to "" and _adds is equal to "" then
set _status to "Files " & _mods
else if _mods is equal to "" and _adds is not equal to "" then
set _status to "Files " & _adds
else
set _status to "Files " & _mods & " and " & _adds
end if
display notification _status with title "Xcode Git status" subtitle "⎇ " & _curBranch
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment