Reputation: 7443
Trying to figure out how to activate a window in iTerm with a particular name/title with applescript. My latest effort:
#!/usr/bin/osascript
tell application "iTerm2"
set winlist to every window
repeat with win in winlist
set the_title to title of window win
if the_title contains "Development" then
activate win
end if
end repeat
end tell
But I'm getting this error:
execution error: iTerm got an error: Can’t make title of window (window id 203) into type specifier. (-1700)
The window is in full screen mode so I'm not sure if that makes a difference or not.
Upvotes: 2
Views: 2141
Reputation: 7555
The following example AppleScript code works for me under macOS High Sierra, in Script Editor, to switch to the full screen window containing the target name:
tell application "iTerm"
set winlist to every window
repeat with win in winlist
set the_title to name of win
if the_title contains "Development" then
activate
set index of win to 1
end if
end repeat
end tell
If the target window is not in full screen is just raises it to the front.
Upvotes: 3