Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Simpler system for running code after InteractiveShell is initialised #914

Closed
takluyver opened this Issue · 4 comments

3 participants

@takluyver
Owner

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.
@minrk minrk referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@minrk
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.

@takluyver
Owner
@minrk
Owner

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

@minrk minrk referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@minrk minrk referenced this issue from a commit in minrk/ipython
@minrk minrk 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
@minrk minrk closed this
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@minrk minrk 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
778588b
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.