I want to detect if a Jupyter Notebook is being executed in a terminal e.g. via ipython --TerminalIPythonApp.file_to_run command, as opposite to a HTML enabled notebook. Note that this is different from detecting if the Python code is run with python or within a notebook.
Based on this I can format Pandas DataFrames suitable either for HTML or for terminal display.
How can I detect if a notebook is outputting to a terminal?

