Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dyuri/xontrib-pyrtn

Xontrib to store the python return value of commands for the session, mimicking ipython's In/Out.
https://github.com/dyuri/xontrib-pyrtn

python xonsh xontrib

Last synced: 3 months ago
JSON representation

Xontrib to store the python return value of commands for the session, mimicking ipython's In/Out.

Awesome Lists containing this project

README

        


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:

```bash
xpip install xontrib-pyrtn
# or: xpip install -U git+https://github.com/dyuri/xontrib-pyrtn
```

## Usage

```bash
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

```bash
$ xontrib load pyrtn
$ $PROMPT = "[{pyhistnum}]$ "
[2]$ [12 * 3 + 6]
[42]
[3]$ In[2]
"[12 * 3 + 6]\n"
[4]$ Out[2] + [1]
[42, 1]
[5]$
```

## Credits

This package was created with [xontrib cookiecutter template](https://github.com/xonsh/xontrib-cookiecutter).