Applescript (osascript): opening split panes in iTerm 2 and performing commands

前端 未结 6 1288
生来不讨喜
生来不讨喜 2021-01-05 01:14

The following works to open two tabs in iTerm 2.

I can\'t seem to figure out how to get this to using split panes instead.

I\'ve tried appl

6条回答
  •  死守一世寂寞
    2021-01-05 02:12

    In case it's helpful: I have the similar problem of wanting a key combo shortcut in iTerm to split panes and have the new pane inherit the title of the original session. I came up with the following, which solves that problem and relies less on sending keystrokes (though I'd love to eliminate them entirely).

    tell application "iTerm"
        tell the current terminal
            tell the current session
                set the_name to get name
                tell i term application "System Events" to keystroke "d" using {command down, shift down}
            end tell
    
            tell the current session
                set name to the_name
            end tell
        end tell
    end tell
    

    I am using BetterTouchTool to bind a key combo -- namely, cmd+' -- to the execution of this AppleScript. (I find that it gets screwy for some key combos, I would naively guess because you are effectively holding that key combo down on top of whatever keystrokes the script sends. I haven't chased down how to define the keyboard shortcut in the preferences of iTerm itself. I suspect that might mitigate the issue.)

提交回复
热议问题