def get_shell_history():
<EOL>if '<STR_LIT>' in globals():<EOL><INDENT>a = list(get_ipython().history_manager.input_hist_raw)<EOL>a.reverse()<EOL>return a<EOL><DEDENT>elif '<STR_LIT>' in _os.environ:<EOL><INDENT>try:<EOL><INDENT>p = _os.path.join(_settings.path_user, "<STR_LIT>", "<STR_LIT>")<EOL>a = read_lines(p)<EOL>a.reverse()<EOL>return a<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>import wx<EOL>for x in wx.GetTopLevelWindows():<EOL><INDENT>if type(x) in [wx.py.shell.ShellFrame, wx.py.crust.CrustFrame]:<EOL><INDENT>a = x.shell.GetText().split("<STR_LIT>")<EOL>a.reverse()<EOL>return a<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return ['<STR_LIT>']<EOL>
This only works with some shells.