Skip to main content

A hackable Python REPL with first-class command support

Project description

PyKernel

PyPI version Python License: MIT Downloads

A hackable Python REPL with first-class command support.

Install

pip install pykernel-cli

Usage

pykernel
# or
python -m pykernel

Type /help to see all commands.

Flags

Flag Description
--ver Show the current version
--dev Show plugin dev reference

Commands

Core

Command Aliases Description
/help [command] /? /commands List commands or describe one
/exit /quit /q Exit the kernel
/clear /cls Clear the terminal screen
/history [n] /hist Show last n inputs (default 20)
/run <file.py> Execute a Python file
/reset Clear the execution namespace
/alias <new> <target> Create an alias for a command

Inspector

Command Aliases Description
/vars /ls /env List variables in the namespace
/who <name> Show detailed info about a variable
/doc <name> Show a variable's docstring
/source <name> /src Show source code of a function/class
/del <name> /rm Delete a variable
/timeit <expr> Time an expression

Shell

Command Aliases Description
/sh <cmd> /! Run a shell command (output stored in _out)
/cd <path> Change working directory
/pwd Print working directory
/ls [path] List directory contents

Snippets

Command Description
/snip save <name> Save last history entry as a snippet
/snip write <name> Create a snippet in $EDITOR
/snip list List all saved snippets
/snip show <name> Print a snippet's source
/snip run <name> Execute a snippet
/snip edit <name> Edit a snippet in $EDITOR
/snip del <name> Delete a snippet

Plugins

Drop a .py file with a register(registry) function into ~/.pykernel/plugins/:

def register(reg):
    @reg.command("hello", help="Say hello")
    def cmd_hello(ctx, *args):
        ctx.print("Hello!")

Plugins load automatically on startup. Run pykernel --dev for the full plugin dev reference.

Config

Edit ~/.pykernel/config.toml:

[kernel]
prompt = ">>> "
theme  = "dark"   # dark | light | none

Troubleshooting

pykernel command not found on Windows?

Run with python -m pykernel instead, or add Python's Scripts folder to your PATH: C:\Users\<you>\AppData\Local\Programs\Python\Python3xx\Scripts\

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykernel_cli-1.4.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykernel_cli-1.4.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file pykernel_cli-1.4.0.tar.gz.

File metadata

  • Download URL: pykernel_cli-1.4.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pykernel_cli-1.4.0.tar.gz
Algorithm Hash digest
SHA256 92bd267eb3ff6a957fa6b7040b08b358cbe557f25c44dc91457edafdba560296
MD5 247f08faf0305dba1e2f599ff2b74cf9
BLAKE2b-256 ca3ae6006ebadeb1d3ef758d79d8da1eb0525d1a9c6d4e2911906f7c13a2e33e

See more details on using hashes here.

File details

Details for the file pykernel_cli-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: pykernel_cli-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for pykernel_cli-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 428e4f3772fa2490138b8945a94ed2a67576952283973b2c73855b9748bb9fd6
MD5 1b9c8435229da9f72f277634ad28dbdd
BLAKE2b-256 ba4bedec5d4a334dbe6a0a020e71404cfc2930f1a02970c0d3ea26138919f9d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page