Skip to content

Instantly share code, notes, and snippets.

@Kimtaro
Created March 9, 2016 09:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kimtaro/2f454334da0a7beeb93e to your computer and use it in GitHub Desktop.
Save Kimtaro/2f454334da0a7beeb93e to your computer and use it in GitHub Desktop.
Split windows in TextMate
set dock_position to do shell script "defaults read com.apple.dock orientation"
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_width to item 1 of dock_dimensions
set dock_height to item 2 of dock_dimensions
end tell
tell application "Finder"
set the_bounds to bounds of window of desktop
set the_width to item 3 of the_bounds
set the_height to item 4 of the_bounds
end tell
if (dock_position is equal to "left") then
set top_left to dock_width
set the_width to the_width - dock_width
else if (dock_position is equal to "right") then
set top_left to 0
set the_width to the_width - dock_width
else
set top_left to 0
set the_height to the_height - dock_height
end if
set left_window_bounds to {top_left, 0, (the_width / 2), the_height}
set right_window_bounds to {(the_width / 2), 0, top_left + the_width, the_height}
tell application "TextMate" to activate
tell application "System Events"
set window_menu to ((process "TextMate")'s (menu bar 1)'s ¬
(menu bar item "Window")'s (menu "Window"))
set first_window to front window of application "TextMate"
click menu item "Move Tab to New Window" of window_menu
set new_window to front window of application "TextMate"
click menu item (name of first_window) of window_menu
tell application "TextMate" to set bounds of first window to left_window_bounds
click menu item (name of new_window) of window_menu
tell application "TextMate" to set bounds of first window to right_window_bounds
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment