ipython/ipython — pull request #1949 by tkf (2012-06-13 15:01:04+00:00)
Title: Introduce Notebook Magics

This change introduces two notebook magic commands:

1. %pnd -- Return the notebook directory.
This is like %pwd but returns where the notebook is.
2. %cdnb -- Change directory to where the notebook locates.

These commands are useful when you want to access some supplemental python scripts in the notebook. Having hard-coded `%cd IPYTHON/NOTEBOOK/DIRECTORY` is not good solution.

These magic commands work only when the notebook is in the directory which is configured by the profile. If notebook server using different directory than the configured variable (for example, notebook_dir is set via command line option), these magic commands misbehaves.

To fix this issue, I think it's better to send some information about notebook to the kernel from the notebook server when the kernel is started.