Discussion:
[iterm2-discuss] Automated Window Size and Placement
Chip Gwyn
2018-07-05 13:12:04 UTC
Permalink
I feel sure this is completely possible but I can't quite work out how.

I want to run a single command, click a button, whatever, and have all my
windows pop up in the right places and at the right size. To be clear
this is separate windows, not panes in a window.

I pretty much always have six windows open at once. Each used for
different operations in my daily work. Because I'm one of those
"everything has to line up" dorks I spend a few minutes whenever I must
relaunch iTerm2 re-arranging and sizing all of the windows. Surely
there's a way I can say, open a window at (some-coordinate) with a size of
(rows, lines) and repeat this however many times I need with correct values
filled in.

Basically I want to execute something that pops up my six windows, sized
appropriately, and in the their correct locations.

I *think* this can be done with just Applescript but I don't know the args
to use with iTerm to get it opened right.

Anyone have any pointers or previous work that will allow this
functionality?

Thanks!

--chip
--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-07-06 06:38:46 UTC
Permalink
A saved arrangement might do the job. Lay out the windows properly and then
do Window>Save Window Arrangement. You can later restore it from
Window>Restore Window Arrangement.

If that's not good enough, you can use Applescript 🀢

Here's an example with two windows:

*tell* *application* "iTerm2"

*set* w1 *to* (*create window with default profile*)

*set* w2 *to* (*create window with default profile*)

*set* bounds *of* w1 *to* {0, 22, 700, 900}

*set* bounds *of* w2 *to* {700, 22, 1440, 900}

*end* *tell*

If you're feeling adventurous, you can grab the nightly build and do it
with https://iterm2.com/python-api

Here's an example script:

import iterm2
connection=await iterm2.Connection.async_create()
app=await iterm2.async_get_app(connection)
w=await app.async_create_window()
await w.async_set_frame(iterm2.Frame(iterm2.Point(0, 22), iterm2.Size(700,
878)))
w=await app.async_create_window()
await w.async_set_frame(iterm2.Frame(iterm2.Point(700, 22),
iterm2.Size(740, 878)))
Post by Chip Gwyn
I feel sure this is completely possible but I can't quite work out how.
I want to run a single command, click a button, whatever, and have all my
windows pop up in the right places and at the right size. To be clear
this is separate windows, not panes in a window.
I pretty much always have six windows open at once. Each used for
different operations in my daily work. Because I'm one of those
"everything has to line up" dorks I spend a few minutes whenever I must
relaunch iTerm2 re-arranging and sizing all of the windows. Surely
there's a way I can say, open a window at (some-coordinate) with a size of
(rows, lines) and repeat this however many times I need with correct values
filled in.
Basically I want to execute something that pops up my six windows, sized
appropriately, and in the their correct locations.
I *think* this can be done with just Applescript but I don't know the args
to use with iTerm to get it opened right.
Anyone have any pointers or previous work that will allow this
functionality?
Thanks!
--chip
--
You received this message because you are subscribed to the Google Groups
"iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chip Gwyn
2018-07-06 11:14:47 UTC
Permalink
The window arrangement worked perfectly!

Seeing the python API, I'm imagining other nifty things I might be able to
do. Thanks for the reminder of that.

Thanks for all the help!

--chip
Post by George Nachman
A saved arrangement might do the job. Lay out the windows properly and
then do Window>Save Window Arrangement. You can later restore it from
Window>Restore Window Arrangement.
If that's not good enough, you can use Applescript 🀢
*tell* *application* "iTerm2"
*set* w1 *to* (*create window with default profile*)
*set* w2 *to* (*create window with default profile*)
*set* bounds *of* w1 *to* {0, 22, 700, 900}
*set* bounds *of* w2 *to* {700, 22, 1440, 900}
*end* *tell*
If you're feeling adventurous, you can grab the nightly build and do it
with https://iterm2.com/python-api
import iterm2
connection=await iterm2.Connection.async_create()
app=await iterm2.async_get_app(connection)
w=await app.async_create_window()
await w.async_set_frame(iterm2.Frame(iterm2.Point(0, 22), iterm2.Size(700,
878)))
w=await app.async_create_window()
await w.async_set_frame(iterm2.Frame(iterm2.Point(700, 22),
iterm2.Size(740, 878)))
Post by Chip Gwyn
I feel sure this is completely possible but I can't quite work out how.
I want to run a single command, click a button, whatever, and have all my
windows pop up in the right places and at the right size. To be clear
this is separate windows, not panes in a window.
I pretty much always have six windows open at once. Each used for
different operations in my daily work. Because I'm one of those
"everything has to line up" dorks I spend a few minutes whenever I must
relaunch iTerm2 re-arranging and sizing all of the windows. Surely
there's a way I can say, open a window at (some-coordinate) with a size of
(rows, lines) and repeat this however many times I need with correct values
filled in.
Basically I want to execute something that pops up my six windows, sized
appropriately, and in the their correct locations.
I *think* this can be done with just Applescript but I don't know the
args to use with iTerm to get it opened right.
Anyone have any pointers or previous work that will allow this
functionality?
Thanks!
--chip
--
You received this message because you are subscribed to the Google Groups
"iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...