I'm not exactly sure how I would approach this, but I did a small amount of research and it seems that you can use AppleScript to get the current window title and then compare that to the expected window title of Terminal.
From: MacOSX: get foremost window title
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
tell process frontAppName
tell (1st window whose value of attribute "AXMain" is true)
set windowTitle to value of attribute "AXTitle"
end tell
end tell
end tell
return {frontAppName, windowTitle}