I have some code in my .bashrc that sets the terminal window title using the currently running command and it works great in Unity, where the terminal is in a window. However, when I'm logging in with the Ctrl + Alt + F1 terminal (whatever it's called), my prompt gets filled with garbage that is various escape sequences that set the (nonexistent) window title.

How can I detect from within a bash script if I'm in one or the other?