[IPython-dev] [IPython 5] [Docs] Custom Terminal Prompts

Carl Smith carl.input at gmail.com
Sun Jul 10 19:11:32 EDT 2016


No problem at all, Fernando.

I did have a go at it based on the code Thomas pointed to, but couldn't
figure out how to use the reference to `self.shell.execution_count`. When
it's used directly, as it is in the IPython source (passed through `str`),
you end up with something like this:

    In [<traitlets.traitlets.Int at 0x104800b70>]:

Using the `default_value` and `default_value_repr` methods, gives you the
number, but it was always `1`, no matter what the actual input number was.

I'll have another go at it soon, and am happy to add something to the docs
once I figure it out, but just switched to using tmux and the ne editor
this week too, so have a ton of little things to figure out and configure
at the moment.

Best,

-- Carl Smith
carl.input at gmail.com

On 11 July 2016 at 00:01, Fernando Perez <fperez.net at gmail.com> wrote:

> BTW, Carl, if you come up with a nice example that works for you, a small
> PR contribution to the docs would be greatly appreciated, so it helps
> others in the future!
>
> Cheers
>
> f
>
> On Sat, Jul 9, 2016 at 12:30 PM, Carl Smith <carl.input at gmail.com> wrote:
>
>> Thanks Thomas. Appreciated.
>>
>> On Sat, 9 Jul 2016 17:07 Thomas Kluyver, <takowl at gmail.com> wrote:
>>
>>> On 9 July 2016 at 15:59, Carl Smith <carl.input at gmail.com> wrote:
>>>
>>>> Just been trying to set up a custom prompt with the new prompt_toolkit
>>>> features, and couldn't figure it out from the IPython docs. Perhaps adding
>>>> an example class would make things clear.
>>>
>>>
>>> In the absence of examples in the docs, the prompt classes in the code
>>> might be worth a look:
>>>
>>>
>>> https://github.com/ipython/ipython/blob/master/IPython/terminal/prompts.py
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> https://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> https://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
>
> --
> Fernando Perez (@fperez_org; http://fperez.org)
> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
> fernando.perez-at-berkeley: contact me here for any direct mail
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> https://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20160711/50eeb42e/attachment.html>


More information about the IPython-dev mailing list