Last active
August 29, 2017 18:59
-
-
Save TheCase/9eed3a226613a36c13da0dbf84ad833b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Config Section | |
# columns, rows per window | |
set cols to 80 | |
set rows to 50 | |
# first window, pixels down from top of screen | |
set top_margin to 0 | |
# pixels per terminal column - this might vary by screen - use screencap to show pixel count | |
# ie. 500 pixels for a 50 char window = 10 | |
set pixels_per to 10 | |
# pixel side space between windows | |
set gap to 6 | |
# calcuated, do not edit below this line | |
################################################### | |
set wpixels_wide to ((rows * pixels_per) + gap) | |
set wpixels_high to (cols * pixels_per) | |
# calc how many windows will fit on the screen | |
tell application "Finder" | |
set _b to bounds of window of desktop | |
set screen_width to item 3 of _b | |
set screen_height to item 4 of _b | |
end tell | |
set windows_wide to round ((screen_width - wpixels_wide) / wpixels_wide) rounding up | |
#display dialog screen_width & "x" & wpixels_wide & " windows_w: " & windows_wide | |
set window_id to 1 | |
set row to 0 | |
set col to 0 | |
tell application "Terminal" | |
set numWindows to (count windows) | |
if (numWindows > windows_wide) then | |
set numWindows to windows_wide | |
end if | |
set start_x to ((screen_width - (numWindows * wpixels_wide)) / 2) | |
repeat | |
if (col > (windows_wide - 1)) then | |
set row to row + 1 | |
set col to 0 | |
end if | |
set start_y to (wpixels_high * row) | |
if (start_y > screen_height) then | |
set start_y to ((wpixels_wide * row) - screen_height) | |
set start_x to start_x + 50 | |
end if | |
if (window window_id exists) then | |
tell window window_id | |
set pos_x to (start_x + (wpixels_wide * col)) | |
set pos_y to (top_margin + (start_y * row)) | |
set position to {pos_x, pos_y} | |
set number of columns to cols | |
set number of rows to rows | |
#display dialog "wid: " & window_id & " row: " & row & " col: " & col & " xy: " & pos_x & ":" & pos_y | |
end tell | |
set window_id to window_id + 1 | |
set col to col + 1 | |
else | |
exit repeat | |
end if | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment