Skip to main content

XmyShell

XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime. The main process is Python, and shell commands are executed in subprocesses. It provides a persistent Python namespace, inline Python evaluation, and command output capture. It can be useful if you want Python evaluation in a shell or execute shell command conveniently in Python REPL environment.

Get started

Installation

pip install xmyshell

Start

$ xmyshell
XmyShell 0.1.0
Initialized with 296ms.
Username@hostname   ~ 0ms
❯

Learn more through help.

 help

Features

Command Line Features

  • Persistent Python namespace across commands (variables, imports, functions)
  • Expand inline Python expressions within {}, using independent namespace.
❯ mkdir {" ".join(f"test{i}" for i in range(10))}
❯ ls
test0  test1  test2  test3  test4  test5  test6  test7  test8  test9
  • Evaluate and print Python expressions with print
❯ print 1 + 1
2
  • Execute Python statements with pyexec
❯ pyexec files = [f for f in os.listdir('.') if f.endswith('.py')]
❯ print len(files)
3
  • Capture command output into a Python variable with =>.
❯ which python => path
❯ print path
/usr/bin/python
❯ cd {dirname(path)}
❯ pwd
/usr/bin
  • Redirect the output of Python commands (print, pyexec) with |>
❯ print "\n".join(str(i) for i in range(100)) |> grep 42 => result
❯ print result
42
  • Built-in source command to run python scripts.
❯ which python
/usr/bin/python
❯ source .venv/bin/activate_this.py
❯ which python
/tmp/test/.venv/bin/python
  • Built-in export command.
❯ pyexec foo = "foo"
❯ export ENV_VAR={foo}bar
❯ print ENV_VAR
foobar
  • Built-in import command.
❯ import numpy as np
❯ from math import *
  • Reload with reload command.
❯ reload
  • Update xmyshell (optionally to a specific version).
❯ udpate

or

❯ update 0.1.3
  • Alias
❯ alias ll='ls -lh'
❯ unalias ll
  • Syntax highlighting via prompt_toolkit
  • Powerful auto-completion, history search, and automatic bracket/quote pairing
  • Startup configuration: ~/.xmyshell/config.py loaded at launch
  • Cross-platform (Windows, Linux, macOS)

Built-in Helper Functions

  • getlogin() Returns the current username.

  • getcwd() Returns the absolute path of the current working directory.

  • dirname(path) Returns the parent directory of a path.

  • basename(path) Returns the final component of a path.

  • cat(file) Shortcut for open(file).read().

  • alias(altname, target) Same as the command.

  • unalias(altname) Same as the command.

Reserved global varibles

  • exit_code The exit code of the last command.

  • exec_duration The duration which last command took.

  • HOME_DIR The home directory, similar to ~.

  • PROFILE The path of config file.

Keyboard Shortcuts

  • ↑↓ -> Navigate through command history.
  • -> Apply selected history entry to the prompt.
  • Ctrl+R -> Reverse incremental searching (history).
  • Ctrl+Z -> Undo.
  • Ctrl+Y -> Redo.
  • Ctrl+D -> Exit XmyShell.
  • Auto bracket/parenthesis/quote pairing

Limitations

XmyShell is Python‑first. This brings power, but also intentional trade‑offs.

  • No source for shell scriptssource executes Python files via runpy.run_path(). Shell scripts (e.g., venv/bin/activate) won't work; use activate_this.py instead.

  • No deactivate — This is a shell function, not a real command. Virtual environments can be deactivated by reloading environment (reload) or manually restarting a session.

  • Shell scripts cannot modify the current environment — Every external command runs in a fresh subprocess; cd, export, aliases, and function definitions inside a script are lost on exit.

  • No pipelines between built‑in commandsprint and pyexec do not support |. Use Python variables to pass data.

  • External command overhead — Each subprocess spawns with minor delays.

Why? XmyShell is NOT a Bash replacement. It's a Python‑native environment for those who want Python's power at the command line.

Release files for xmyshell 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xmyshell 0.2.6
File Size Uploaded
xmyshell-0.2.6.tar.gz 47.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xmyshell 0.2.6
File Interpreter ABI Platform
xmyshell-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 97.1 kB

Release files / xmyshell-0.2.6.tar.gz

Download URL xmyshell-0.2.6.tar.gz
Size 47.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ef90504b292424d17161ea4d0b3e3aecd1c97553a6b771f59961084e6bd29aea
BLAKE2b-256 checksum
How to use checksums
398258c3cb04dcfe405522e240908ec24ccb74ecad1a7412083a60464b7cdc61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / xmyshell-0.2.6-py3-none-any.whl

Download URL xmyshell-0.2.6-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c0205b66812e54ea229650c8cc8809edce8cba2b24d554b8a78c151511db04a
BLAKE2b-256 checksum
How to use checksums
3030151317aa2a5690fb80983a3a956ad4be79632a740008b9a18d9f9d1b356b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page