Open jsbain opened 8 years ago
history
property (?) then I may be the wrong person for the job :)
objc_util
?) Of course "commands" can be implemented by saying builtins.save_history = object()
and making the displayhook react specially to that, but then you might as well make it a normal function.atexit
s, I'll need to check that though. (Edit: still doesn't, tested with atexit.register(lambda: open(os.path.expanduser("~/Documents/atexit_test.txt"), "wb").close())
.)I thought in a recent beta that atexit was supported, though I don't think it runs when killed by the os for memory reasons, or when crashing, so maybe has little value.
I thought you had done some work monkey patching the _stdoutcatcher, but maybe my memory is fuzzy. My thinking would be to log to a file each console command as it is run, then restore in startup. I am not sure if there is another "standard" method to hook into console commands? I guess, for example, whenever you append to Out, we could store the new history commands.... Okay, I guess I know where to look now.
Ah, atexit
hooks run when you do sys.exit()
, not when the app exits.
What I did "back then" was related to the autocompletion in the interactive console. Before Pythonista 2 the completion list was built by injecting a bit of Python code that printed the completions to stdout
, which was then captured by Pythonista and shown in the completion list. I managed to patch that so it would show a custom suggestion at the top of the list every time, but there was no way to get the full text of the partial line typed at that point (and no way to tell whether stdout was currently in "normal" or "autocomplete list" mode, so any patching may also have affected normal output).
exposes the current console command history as a list of strings. This can also be set via
is it possible to enable a stdin hook which stores history to a file, which is then restored on reload? or perhaps an atexit which reads and stores current history.