[IPython-User] formatting console terminal prompt?

MinRK benjaminrk@gmail....
Thu Mar 22 20:34:44 CDT 2012


The prompt templates use Python's string Formatter template stuff.

As seen here<https://github.com/ipython/ipython/blob/master/IPython/core/prompts.py#L145>,
r'\#'
is shorthand for:

    '{color.number}' '{count}' '{color.prompt}'

If you want to change the formatting for the number, that's 'count'.  So I
think what you want is:

    c.PromptManager.in_template = 'In [{color.number}' '{count:03d}'
'{color.prompt}]: '

This seems to have the desired effect in my terminal.

-MinRK

On Thu, Mar 22, 2012 at 17:15, reckoner <reckoner@gmail.com> wrote:

> With respect to the qtconsole, I have successfully managed to format the
> number that is contained in the In[] prompt by setting this in the
> configuration file:
>
> c.IPythonWidget.in_prompt = 'In [<span
> class="in-prompt-number">%03i</span>]: '
>
> This leaves 3 formatted slots for the digit in the prompt? I tried doing
> something similar with the console
>
> c.TerminalInteractiveShell.prompt_in1 = 'In [\\#]: '
>
> But I can't figure out how to make the same formatting change here. That
> is, to make the digit contained in the brackets to have 3 formatted slots.
>
> Thanks!
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120322/08009a3e/attachment.html 


More information about the IPython-User mailing list