Resize a window with Applescript in iTerm2

543 views
Skip to first unread message

Ralf Weber

unread,
Apr 4, 2017, 11:59:45 AM4/4/17
to iterm2-...@googlegroups.com
Moin!

I want to resize a window I create with apple script and have the
following code, which syntactically looks right from the Apple Script
editor:

tell application "iTerm"
activate
set myterm to (create window with default profile)
tell myterm
set number of columns to 105
set number of rows to 35
tell current session of myterm
write text "ssh myhost"
write text "tmux attach -t overview || tmux new-session -s overview"
end tell
end tell
end tell


however I do get the following when executing:

error "iTerm got an error: Can’t set columns of window id 1596 to
105." number -10006 from columns of window id 1596

is this a bug or am I'm doing something wrong.

TIA and so long
-Ralf

George Nachman

unread,
Apr 9, 2017, 12:21:48 PM4/9/17
to iterm2-...@googlegroups.com
I'm pretty sure Applescript was created as a joke by people who don't like us.

sessions are not a property of windows, but of tabs. Also, "number of" is some magic to do with arrays, not scalars (I think). Here's a working script:

tell application "iTerm2"
activate
set myterm to (create window with default profile)
tell first session of first tab of myterm
set columns to 105
set rows to 35
tell current session of myterm
write text "ssh myhost"
write text "tmux attach -t overview || tmux new-session -s overview"
end tell
end tell
end tell

-Ralf

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ralf Weber

unread,
Apr 11, 2017, 2:56:25 AM4/11/17
to iterm2-...@googlegroups.com
Moin!

On 9 Apr 2017, at 18:21, George Nachman wrote:

> I'm pretty sure Applescript was created as a joke by people who don't like
> us.
I'm not disagreeing on that.

> sessions are not a property of windows, but of tabs. Also, "number of" is
> some magic to do with arrays, not scalars (I think). Here's a working
> script:
>
> tell application "iTerm2"
> activate
> set myterm to (create window with default profile)
> tell first session of first tab of myterm
> set columns to 105
> set rows to 35
> tell current session of myterm
> write text "ssh myhost"
> write text "tmux attach -t overview || tmux new-session -s overview"
> end tell
> end tell
> end tell
That does the job. Thanks a lot as always for your superb support.

So long
-Ralf
Reply all
Reply to author
Forward
0 new messages