[TxMt] Re: Switch back to editor window after command

Josh Cheek josh.cheek at gmail.com
Thu Apr 29 16:42:30 UTC 2010


If anyone googles how to do this, here is the solution we found, it works
with unsaved windows (hence the "untitled", you would have to change that
depending on your use)

----------

In the command, execute the system comand (ours is Ruby, so backticks)
`osascript switch_windows.applescript`

----------

Then in your Support directory, the file: switch_windows.applescript

tell application "TextMate"
    activate
end tell
tell application "System Events"
    set found_window to false
    set all_windows to every window of process "TextMate"
    repeat with w in all_windows
        if name of w contains "untitled" then
            set editor_window to name of w
            set found_window to true
        end if
    end repeat

    if found_window then

        tell process "TextMate"
            tell menu bar 1
                tell menu bar item "Window"
                    tell menu "Window"
                        click menu item editor_window
                    end tell
                end tell
            end tell
        end tell
    end if
end tell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20100429/4d83b99c/attachment.html>


More information about the textmate mailing list