Skip to content
This repository

Simpler system for running code after InteractiveShell is initialised #914

Closed
takluyver opened this Issue October 20, 2011 · 4 comments

3 participants

Thomas Kluyver Min RK markvoorhies
Thomas Kluyver
Collaborator

A very common need for config is to run code after the InteractiveShell is initialised - e.g. to define extra magics or aliases, or to import modules. Currently, the user has to track down exec_lines in the config file, and put their code inside a string (i.e. it doesn't get syntax highlighted etc.), or save a file in a suitable place, and add it to exec_files.

I propose either:

  • A file in the profile directory which is automatically run in the shell if it is present, as an addition to the user-specified exec_files. Something like ipython_startup.py.
  • A directory, similar to the /etc/rcN.d/ folders on Linux, in which any files found are run in a predictable order (i.e. to allow prefixes 00-99 if desired). This would allow customisations to be easily distributed: download a file, drop it in your IPYTHONDIR/profile_default/startup/ directory, and an extra magic function will be available.
Min RK minrk referenced this issue from a commit October 21, 2011
Commit has since been removed from the repository and is no longer available.
Min RK
Owner

I am +1 on this. It's frustrating that we boast this new config system, but a lot of what people want has to be done through the ugly strings of code. I know we have Extensions and Plugins, but those are too heavyweight for what most people want.

In fact, this is quite trivial to implement see here for a working implementation, but we should get consensus before adding something like this.

markvoorhies

Min's implementation (e80f7aa) works for me for defining local magic. Compared to finding and editing ipython_config.py, this is way easier to figure out. It might be nice to reference this in either the '%quickref' or '%magic' documentation so that it's easy to discover from an interactive session.

Thomas Kluyver
Collaborator
Min RK
Owner

@takluyver - yes, that would be easy. I'll do it before making a PR

Min RK minrk referenced this issue from a commit October 30, 2011
Commit has since been removed from the repository and is no longer available.
Min RK minrk referenced this issue from a commit in minrk/ipython October 21, 2011
Min RK add startup_dir to profiles
Any .py or .ipy file in this directory will be run at startup.
Files are run in in lexicographical order, as described in #914
7c21f7c
Min RK minrk closed this November 07, 2011
Brian E. Granger ellisonbg referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.