https://github.com/dgelessus/pythonista_startup
I'm a big fan of the pythonista_startup feature (thanks @omz!) and use it a lot. Mine grew to a package with six submodules (is this normal?) so I decided to put it up on GitHub.
Installation is simple - back up your existing pythonista_startup file/folder, then run these commands in stash:
mkdir site-packages/pythonista_startup
cd site-packages/pythonista_startup
git clone https://github.com/dgelessus/pythonista_startup.git
And to update:
cd site-packages/pythonista_startup
git pull
Features:
Almost all of them are turned off by default as not everyone will find them useful or because they're unstable. To turn them on, edit __init__.py and uncomment the entries that you want to have enabled.
- Anti-globals-clearing mechanism as originally posted here. (Optional)
- Custom
sys.displayhookandsys.excepthookfor fancy colors in the interactive prompt, an IPython-likeOuthistory, and cleaner exception display (only for code run interactively). (Optional, colors unsuitable for dark themes) - Makes "hidden" built-in types (like
function,instancemethodandcode) accessible as globals. (Optional, possibly not very useful) - Enables the standard
faulthandlermodule to record a Python traceback when Pythonista hard-crashes. (Optional, Python 3 only, slightly untested) - Patches for the
sysstreams to make some "normal terminal" scripts work. (Optional, enabled by default) - Proper exception handling for any code run in
pythonista_startupand the submodules - by default Pythonista just ignores all exceptions that happen there. - Experimental "preflight hook" support to run code every time a script is run from the Pythonista editor. (Optional, very unstable, probably breaks with every Pythonista update)
It is possible to add custom features in their own subfiles. Each submodule contains a run function, which is run by the main __init__.py. Submodules are not detected automatically, you need to add new ones to the __init__.py by hand.