[IPython-dev] Dynamically changing the prompt from within a magic

Bradley M. Froehle brad.froehle at gmail.com
Fri Aug 3 13:29:10 EDT 2012


Otherwise, the function magic function would look something like:

from IPython.core.magic import magics_class, Magics, line_magic
from IPython.utils import text
@magics_class
class PromptMagics(Magics):

    @line_magic
    def prompt(self, line):
        """Get or update the input prompt.

        Usage:
          %prompt [in_template]

        If called without arguments, return the prompt `in_template`.
        Otherwise set the `in_template` to the given value.
        """
        pm = self.shell.prompt_manager
        if line:
            pm.in_template = text.unquote_ends(line)
        else:
            return pm.in_template



More information about the IPython-dev mailing list