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
sourcecommand to run python scripts.
❯ which python
/usr/bin/python
❯ source .venv/bin/activate_this.py
❯ which python
/tmp/test/.venv/bin/python
- Built-in
exportcommand.
❯ pyexec foo = "foo"
❯ export ENV_VAR={foo}bar
❯ print ENV_VAR
foobar
- Built-in
importcommand.
❯ import numpy as np
❯ from math import *
- Reload with
reloadcommand.
❯ reload
- Update xmyshell (optionally to a specific version).
❯ udpate
or
❯ update 0.1.3
- Alias
❯ alias ll='ls -lh'
❯ unalias ll
- Lists, tuples, generators, etc. will be expanded into shell arguments.
E.g.
{["arg1", "arg2 xxx"]}will be expanded intoarg1 'arg2 xxx'
Here is an example (though there are other ways to do this, it is just an example )
❯ pip install {cat("requirements.txt").splitlines()}
- Syntax highlighting via
prompt_toolkit - Powerful auto-completion, history search, and automatic bracket/quote pairing
- Startup configuration:
~/.xmyshell/config.pyloaded 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 foropen(file).read(). -
alias(altname, target)Same as the command. -
unalias(altname)Same as the command.
Reserved global varibles
-
exit_codeThe exit code of the last command. -
exec_durationThe duration which last command took. -
SHOW_WELCOMEToggle whether to show welcome message when staring. -
SHELL_CMDShell command line prefix, defaults to["cmd", "/c"]on Windows and["bin/sh", "-c"]on other OS. -
HOME_DIRThe home directory, similar to~. -
PROFILEThe 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
Stubs
You can write your xmyshell script with these imports:
from xmyshell.themes import ... # themes
from xmyshell.stubs import ... # stubs for built-in names
Limitations
XmyShell is Python‑first. This brings power, but also intentional trade‑offs.
-
No
sourcefor shell scripts —sourceexecutes Python files viarunpy.run_path(). Shell scripts (e.g.,venv/bin/activate) won't work; useactivate_this.pyinstead. -
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 commands —
printandpyexecdo 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.
Metadata
Release files for xmyshell 0.2.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xmyshell-0.2.17.tar.gz | 51.7 kB | Without provenance | Details for xmyshell-0.2.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmyshell-0.2.17-py3-none-any.whl | Python 3 | none | any | Details for xmyshell-0.2.17-py3-none-any.whl |
Total release size: 104.8 kB
Release files / xmyshell-0.2.17.tar.gz
| Download URL | xmyshell-0.2.17.tar.gz |
|---|---|
| Size | 51.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9690046dc9968669698bd08526fdf746076d4ee216054f1be9a307fed51ad3c0
|
|
BLAKE2b-256 checksum How to use checksums |
3b8f6e7827aad629c8feb97021246a0e8287be913e817df7690d1f8288d1dfc0
|
| 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.17-py3-none-any.whl
| Download URL | xmyshell-0.2.17-py3-none-any.whl |
|---|---|
| Size | 53.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe523ab70db60eea4e73ad4261ffee60fd0a85201921dc7b6e107b4e56f2581b
|
|
BLAKE2b-256 checksum How to use checksums |
89f5846730f51dcf977a5e97530f632ad0a222f83f5f79f2b4d0ecc537204928
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for xmyshell 0.2.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.