Skip to content

Instantly share code, notes, and snippets.

@jianhu
Created July 20, 2012 09:05
Show Gist options
  • Select an option

  • Save jianhu/3149740 to your computer and use it in GitHub Desktop.

Select an option

Save jianhu/3149740 to your computer and use it in GitHub Desktop.

Revisions

  1. jianhu created this gist Jul 20, 2012.
    18 changes: 18 additions & 0 deletions ObjcCodeBeautifier
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    tell application "Xcode"
    if (frontmost of it = false) then
    return
    end if

    set documentList to source document of it
    set listLength to count of documentList
    if listLength is less than 1 then
    return --no opened source file in working space
    end if

    set filePath to path of item listLength of documentList -- get the last one
    set filePathStr to filePath as text
    if (filePathStr ends with ".m" or filePathStr ends with ".h") then --only format source file
    do shell script "uncrustify -c ~/.uncrustify/objc.cfg --no-backup " & filePathStr -- where the essense resides..
    end if

    end tell