First time here? Check out the FAQ!

Ask Your Question
3

How to get numbered prompt

asked 4 years ago

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?

Preview: (hide)

Comments

Why bother ?

FrédéricC gravatar imageFrédéricC ( 4 years ago )
1

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 ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
4

answered 4 years ago

tmonteil gravatar image

updated 4 years ago

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).

Preview: (hide)
link

Comments

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

vdelecroix gravatar imagevdelecroix ( 4 years ago )

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

Stats

Asked: 4 years ago

Seen: 703 times

Last updated: Apr 27 '20