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?
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
p
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