ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 24 May 2020 11:49:58 -0500How to get numbered prompthttps://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/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?Mon, 27 Apr 2020 09:30:56 -0500https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/Comment by andro for <p>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?</p>
https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51091#post-id-51091Because 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.Tue, 28 Apr 2020 03:26:38 -0500https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51091#post-id-51091Comment by FrédéricC for <p>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?</p>
https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51071#post-id-51071Why bother ?Mon, 27 Apr 2020 11:59:47 -0500https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51071#post-id-51071Answer by tmonteil for <p>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?</p>
https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?answer=51074#post-id-51074You 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).Mon, 27 Apr 2020 12:52:50 -0500https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?answer=51074#post-id-51074Comment by vdelecroix for <p>You can do this :</p>
<pre><code>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
</code></pre>
<p>If you want this to be executed each time Sage is started,
put these three lines in your <code>init.sage</code> file, which by default
is the file <code>~/.sage/init.sage</code> (create it if it does not exist yet).</p>
https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51540#post-id-51540And about customizing the prompt, see [my answer to this other post](https://ask.sagemath.org/question/51536/print-inputoutput-numbers/?answer=51539#post-id-51539).Sun, 24 May 2020 11:49:58 -0500https://ask.sagemath.org/question/51065/how-to-get-numbered-prompt/?comment=51540#post-id-51540