Ask Your Question

How to get numbered prompt

asked 2020-04-27 09:30:56 -0500

andro gravatar image

A lot of Ipython docs show numbered prompts like 'In [4]:'. With Sagemath 9 I only have the prompt 'sage:'. How can you set the prompt?

edit retag flag offensive close merge delete


Why bother ?

FrédéricC gravatar imageFrédéricC ( 2020-04-27 11:59:47 -0500 )edit

Because the manual refers to it., and it allows one to easily reuse previous results from back before the underscore references allow. It's a perfectly legitimate question I would have thought.

andro gravatar imageandro ( 2020-04-28 03:26:38 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2020-04-27 12:52:50 -0500

tmonteil gravatar image

updated 2020-04-27 16:00:05 -0500

slelievre gravatar image

You can do this :

sage: from IPython.terminal.prompts import Prompts
sage: ip = get_ipython()
sage: ip.prompts = Prompts(ip)
In [4]: 1+1
Out[4]: 2
In [5]: 2+2
Out[5]: 4
In [6]: Out[5]^2
Out[6]: 16

If you want this to be executed each time Sage is started, put these three lines in your init.sage file, which by default is the file ~/.sage/init.sage (create it if it does not exist yet).

edit flag offensive delete link more


And about customizing the prompt, see my answer to this other post.

vdelecroix gravatar imagevdelecroix ( 2020-05-24 11:49:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-04-27 09:30:56 -0500

Seen: 53 times

Last updated: Apr 27