README.md
April 18, 2026 · View on GitHub
Store the python return value of commands for the session.
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
xpip install xontrib-pyrtn
# or: xpip install -U git+https://github.com/dyuri/xontrib-pyrtn
Usage
xontrib load xontrib_pyrtn
The xontrib adds two functions to the global namespace - In[] and Out[]. They are similar to ipython's In[] and Out[].
(In() and Out() is also available and does the same thing, except they can be called w/o argument and will show the list of input/output.)
A new PROMPT_FIELD pyhistnum is also added, to be able to include the number of the upcoming command (like in ipython).
Example
$ xontrib load pyrtn
$ $PROMPT = "[{pyhistnum}]$ "
[2]$ [12 * 3 + 6]
[42]
[3]$ In[2]
"[12 * 3 + 6]\n"
[4]$ Out[2] + [1]
[42, 1]
[5]$
Starship
For starship users, the xontrib also updates $PYRTN_HISTNUM after each command so it can be displayed with starship modules.
Example starship.toml snippet:
format = "...${env_var.PYRTN_HISTNUM}..."
[env_var.PYRTN_HISTNUM]
format = "[\\[]($style)[$env_value](bold)[\\] ]($style)"
style = "blue"
Credits
This package was created with xontrib cookiecutter template.