Discussion:
[iterm2-discuss] iTerm 2.9 AppleScript: exec command in split session, evenly tile panes
Yorgos Magos
2015-11-23 20:27:54 UTC
Permalink
Hi

1) I was glad to see much improved AppleScript support in the beta
version, including the split horizontally / vertically set of commands for
sessions. However, there is something that was previously possible for a
session, but now seems to be unavailable: to exec a command in a session.

Previously I could just "exec command my_command" in a newly created
session; the exec command seems to have been removed completely.
Interestingly, there is a nice optional parameter to the create window and
create tab commands: "create tab with profile my_profile command
my_command", but this does not seem to be available for the split commands.

Is there any way to do this, apart from using writing text to the session?

2) Even better, is there going to be a way to tile panes, like tmux C-B
M-5? Specifically, take all tabs in a window and convert them to evenly
sized panes? This would cover #1 above as well, as I could create the
sessions as tabs, then tile them with a single keystroke.

Background:

The main task I have in mind is integration with the network simulator
GNS3. The Mac version has a simple AppleScript built in for iTerm
integration; this just grabs the current session and adds sessions as tabs,
doing an "exec command telnet <host> <port>" on each, to access the
consoles of all routers in the simulation. My ideal workspace would be a
single tab (or multiple if I have more than, say, 6 consoles open at the
same time), transparent so that I can see the topology underneath, with the
sessions evenly laid out as panes. Currently I can do exactly this,
invoking a profile in my custom AppleScript to get the transparency, but
manually laying out the tabs as panes. And every time I reboot the
simulated routers, the telnet connection dies and I have to do the process
again.

Regards,
Yorgos
--
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
2015-12-05 18:57:41 UTC
Permalink
1) That was an oversight. I've added an optional command argument to all
the "split
" commands:
tell application "iTerm2"
tell current session of first window
split vertically with profile "Default" command "echo 1"
split vertically with default profile command "echo 2"
split vertically with same profile command "echo 3"
split horizontally with profile "Default" command "echo 4"
split horizontally with default profile command "echo 5"
split horizontally with same profile command "echo 6"
end tell
end tell

2) Sorry, there's nothing like that at the moment. Please file a feature
request at iterm2.com/bugs.
Post by Yorgos Magos
Hi
1) I was glad to see much improved AppleScript support in the beta
version, including the split horizontally / vertically set of commands for
sessions. However, there is something that was previously possible for a
session, but now seems to be unavailable: to exec a command in a session.
Previously I could just "exec command my_command" in a newly created
session; the exec command seems to have been removed completely.
Interestingly, there is a nice optional parameter to the create window and
create tab commands: "create tab with profile my_profile command
my_command", but this does not seem to be available for the split commands.
Is there any way to do this, apart from using writing text to the session?
2) Even better, is there going to be a way to tile panes, like tmux C-B
M-5? Specifically, take all tabs in a window and convert them to evenly
sized panes? This would cover #1 above as well, as I could create the
sessions as tabs, then tile them with a single keystroke.
The main task I have in mind is integration with the network simulator
GNS3. The Mac version has a simple AppleScript built in for iTerm
integration; this just grabs the current session and adds sessions as tabs,
doing an "exec command telnet <host> <port>" on each, to access the
consoles of all routers in the simulation. My ideal workspace would be a
single tab (or multiple if I have more than, say, 6 consoles open at the
same time), transparent so that I can see the topology underneath, with the
sessions evenly laid out as panes. Currently I can do exactly this,
invoking a profile in my custom AppleScript to get the transparency, but
manually laying out the tabs as panes. And every time I reboot the
simulated routers, the telnet connection dies and I have to do the process
again.
Regards,
Yorgos
--
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...