I'm looking for a way to programmatically terminate the process an iTerm session, essentially the equivalent of Ctrl+C
. I hoped this would be possible via iTerm's Applescript support, but I don't see anything in there to accomplish this. Might there be an alternative approach?
This answer assumes iTerm is running with a visible window and a process running in that window.
The following example AppleScript code will do a ^C:
activate application "iTerm2"
delay 0.2
tell application "System Events" to ¬
keystroke "c" using control down