Neptune is like jupyter notebook inside your terminal.
This tool is made to be configured inside an editor to be really powerful. An Helix configuration is given below, but some (neo)vim/emacs configuration should be possible as well.
Neptune is a dynamic code execution server that allows you to execute Python code snippets with shared global context. It uses a Unix socket for communication between the server and the client, enabling you to send code snippets to be executed within a persistent global context. This setup can be useful for various applications, such as rapid prototyping, debugging, or running code in a controlled environment.
- Shared Global Context: The server maintains a shared global context across multiple code executions, enabling variables and functions defined in previous snippets to be accessed by subsequent ones.
- Flexible Usage: You can use Neptune to run individual code snippets or sequences of code snippets, enabling interactive experimentation and development.
To use Neptune, you need:
- Python 3.x installed on your system.
- Basic knowledge of python programming.
-
Clone the Neptune repository to your local machine:
git clone https://github.com/tdaron/neptune.git
-
Navigate to the Neptune directory:
cd neptune
-
Run the server script to start the Neptune server:
python neptune.py
You can send code snippets to the Neptune server using the provided client script or any other method that can communicate via Unix sockets.
-
Run the client script, providing the code snippet via stdin:
echo -e 'a = 5\nprint(a)' | python client.py
-
The client script sends the code snippet to the Neptune server via the Unix socket, and the server executes it within the shared global context.
- You can define variables, functions, and execute any valid Python code within the snippet.
This script has been originally made to integrate with helix editor. To configure it, just add this to your config:
[keys.normal]
C-k = ["extend_to_line_bounds", ":pipe-to python /home/path/to/client.py"]
[keys.select]
C-k = ["extend_to_line_bounds", ":pipe-to python /home/path/to/client.py"]
Then run neptune.py
wherever you want, and inside helix, select python code then run it with ctrl+k.
(tip: use mip shortcut to select entire block code between 2 blank lines)