gdoubleod gdoubleod - 5 months ago 51
AppleScript Question

iTerm2 Get Current Session Profile?

So I know there is a way to set the session profile via echo -e "\033]50;SetProfile=Foo\a" but is there a way to get the current session's profile?

Answer Source

I didn't find any way to get the name of the profile apart from something like this:

tell application "System Events" to tell process "iTerm"
    keystroke "i" using command down
    set p to value of text field 1 of tab group 1 of group 1 of window 1
    click button 1 of window 1
end tell

You might be able to identify profiles by some properties:

tell application "iTerm" to tell current session of terminal 1
    background color is {0, 0, 0} and transparency is 0.0
end tell

Properties documented in the dictionary:

background color, background image path, bold color, contents, cursor color, cursor_text color, foreground color, id, name, number, selected text color, selection color, transparency, tty

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download