Configuring the ipython command line application — IPython 0.11 documentation

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- Configuration and customization »

# Configuring the ipython command line application

This section contains information about how to configure the ipython command line application. See the configuration overview for a more general description of the configuration system and configuration file format.

The default configuration file for the ipython command line application is `ipython_config.py`. By setting the attributes in this file, you can configure the application. A sample is provided in `IPython.config.default.ipython_config`. Simply copy this file to your IPython directory to start using it.

Most configuration attributes that this file accepts are associated with classes that are subclasses of `Configurable`.

Applications themselves are Configurable as well, so we will start with some application-level config.

## Application-level configuration

Assuming that your configuration file has the following at the top:

    c = get_config()

the following attributes are set application-wide:

terminal IPython-only flags:

`c.TerminalIPythonApp.display_banner`
  A boolean that determined if the banner is printer when ipython is started.
`c.TerminalIPythonApp.classic`
  A boolean that determines if IPython starts in “classic” mode. In this mode, the prompts and everything mimic that of the normal python shell
`c.TerminalIPythonApp.nosep`
  A boolean that determines if there should be no blank lines between prompts.
`c.Application.log_level`
  An integer that sets the detail of the logging level during the startup of ipython. The default is 30 and the possible values are (0, 10, 20, 30, 40, 50). Higher is quieter and lower is more verbose. This can also be set by the name of the logging level, e.g. INFO=20, WARN=30.

Some options, such as extensions and startup code, can be set for any application that starts an `InteractiveShell`. These apps are subclasses of `InteractiveShellApp`. Since subclasses inherit configuration, setting a trait of `c.InteractiveShellApp` will affect all IPython applications, but if you want terminal IPython and the QtConsole to have different values, you can set them via `c.TerminalIPythonApp` and `c.IPKernelApp` respectively.

`c.InteractiveShellApp.extensions`
  A list of strings, each of which is an importable IPython extension. An IPython extension is a regular Python module or package that has a `load_ipython_extension(ip)()` method. This method gets called when the extension is loaded with the currently running `InteractiveShell` as its only argument. You can put your extensions anywhere they can be imported but we add the `extensions` subdirectory of the ipython directory to `sys.path` during extension loading, so you can put them there as well. Extensions are not executed in the user’s interactive namespace and they must be pure Python code. Extensions are the recommended way of customizing ipython. Extensions can provide an `unload_ipython_extension()` that will be called when the extension is unloaded.
`c.InteractiveShellApp.exec_lines`
  A list of strings, each of which is Python code that is run in the user’s namespace after IPython start. These lines can contain full IPython syntax with magics, etc.
`c.InteractiveShellApp.exec_files`
  A list of strings, each of which is the full pathname of a `.py` or `.ipy` file that will be executed as IPython starts. These files are run in IPython in the user’s namespace. Files with a `.py` extension need to be pure Python. Files with a `.ipy` extension can have custom IPython syntax (magics, etc.). These files need to be in the cwd, the ipythondir or be absolute paths.

## Classes that can be configured

The following classes can also be configured in the configuration file for ipython:

- `InteractiveShell`
- `PrefilterManager`
- `AliasManager`

To see which attributes of these classes are configurable, please see the source code for these classes, the class docstrings or the sample configuration file `IPython.config.default.ipython_config`.

## Example

For those who want to get a quick start, here is a sample `ipython_config.py` that sets some of the common configuration attributes:

    # sample ipython_config.py
    c = get_config()

    c.IPythonTerminalApp.display_banner = True
    c.InteractiveShellApp.log_level = 20
    c.InteractiveShellApp.extensions = [
        'myextension'
    ]
    c.InteractiveShellApp.exec_lines = [
        'import numpy',
        'import scipy'
    ]
    c.InteractiveShellApp.exec_files = [
        'mycode.py',
        'fancy.ipy'
    ]
    c.InteractiveShell.autoindent = True
    c.InteractiveShell.colors = 'LightBG'
    c.InteractiveShell.confirm_exit = False
    c.InteractiveShell.deep_reload = True
    c.InteractiveShell.editor = 'nano'
    c.InteractiveShell.prompt_in1 = 'In [\#]: '
    c.InteractiveShell.prompt_in2 = '   .\D.: '
    c.InteractiveShell.prompt_out = 'Out[\#]: '
    c.InteractiveShell.prompts_pad_left = True
    c.InteractiveShell.xmode = 'Context'

    c.PrefilterManager.multi_line_specials = True

    c.AliasManager.user_aliases = [
     ('la', 'ls -al')
    ]

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- Configuration and customization »