xmyshell 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xmyshell-0.1.0/LICENCE ADDED
File without changes
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.4
2
+ Name: xmyshell
3
+ Version: 0.1.0
4
+ Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENCE
8
+ Requires-Dist: prompt-toolkit>=3.0.53
9
+ Dynamic: license-file
10
+
11
+ # XmyShell
12
+
13
+ **`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.
14
+
15
+ ## Features
16
+
17
+ ### Command Line Features
18
+
19
+ - Persistent Python namespace across commands (variables, imports, functions)
20
+ - Expand inline Python expressions within `{}`, using independent namespace.
21
+ ```
22
+ ❯ mkdir {" ".join(f"test{i}" for i in range(10))}
23
+ ❯ ls
24
+ test0 test1 test2 test3 test4 test5 test6 test7 test8 test9
25
+ ```
26
+
27
+ - Evaluate and print Python expressions with `print`
28
+ ```
29
+ ❯ print 1 + 1
30
+ 2
31
+ ```
32
+
33
+ - Execute Python statements with `pyexec`
34
+ ```
35
+ ❯ pyexec files = [f for f in os.listdir('.') if f.endswith('.py')]
36
+ ❯ print len(files)
37
+ 3
38
+ ```
39
+
40
+ - Capture command output into a Python variable with `=>`.
41
+ ```
42
+ ❯ which python => path
43
+ ❯ print path
44
+ /usr/bin/python
45
+ ❯ cd {dirname(path)}
46
+ ❯ pwd
47
+ /usr/bin
48
+ ```
49
+
50
+ - Redirect the output of Python commands (`print`, `pyexec`) with `|>`
51
+ ```
52
+ ❯ print "\n".join(str(i) for i in range(100)) |> grep 42 => result
53
+ ❯ print result
54
+ 42
55
+ ```
56
+
57
+ - Built-in `source` command to run python scripts.
58
+ ```
59
+ ❯ which python
60
+ /usr/bin/python
61
+ ❯ source .venv/bin/activate_this.py
62
+ ❯ which python
63
+ /tmp/test/.venv/bin/python
64
+ ```
65
+
66
+ - Built-in `export` command.
67
+ ```
68
+ ❯ pyexec foo = "foo"
69
+ ❯ export ENV_VAR={foo}bar
70
+ ❯ print ENV_VAR
71
+ foobar
72
+ ```
73
+
74
+ - Built-in `import` command.
75
+ ```
76
+ ❯ import numpy as np
77
+ ❯ from math import *
78
+ ```
79
+
80
+ - Reload with `reload` command.
81
+ ```
82
+ ❯ reload
83
+ ```
84
+
85
+ - Syntax highlighting via `prompt_toolkit`
86
+ - Powerful auto-completion, history search, and automatic bracket/quote pairing
87
+ - Startup configuration: `~/.xmyshell/config.py` loaded at launch
88
+ - Cross-platform (Windows, Linux, macOS)
89
+
90
+ ### Built-in Helper Functions
91
+
92
+ - `getlogin()`
93
+ Returns the current username.
94
+
95
+ - `getcwd()`
96
+ Returns the absolute path of the current working directory.
97
+
98
+ - `dirname(path)`
99
+ Returns the parent directory of a path.
100
+
101
+ - `basename(path)`
102
+ Returns the final component of a path.
103
+
104
+ ### Reserved global varibles
105
+ - `exit_code`
106
+ The exit code of the last command.
107
+
108
+ - `exec_duration`
109
+ The duration which last command took.
110
+
111
+ ### Keyboard Shortcuts
112
+ - `↑↓` -> Navigate through command history.
113
+ - `→` -> Apply selected history entry to the prompt.
114
+ - `Ctrl+R` -> Reverse incremental searching (history).
115
+ - `Ctrl+D` -> Exit XmyShell.
116
+ - Auto bracket/parenthesis/quote pairing
117
+
118
+
119
+ ## Limitations
120
+
121
+ **XmyShell** is Python‑first. This brings power, but also intentional trade‑offs.
122
+
123
+ - **No `source` for shell scripts** — `source` executes Python files via `runpy.run_path()`. Shell scripts (e.g., `venv/bin/activate`) won't work; use `activate_this.py` instead.
124
+
125
+ - **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.
126
+
127
+ - **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.
128
+
129
+ - **No pipelines between built‑in commands** — `print` and `pyexec` do not support `|`. Use Python variables to pass data.
130
+
131
+ - **External command overhead** — Each subprocess spawns with minor delays.
132
+
133
+ **Why?** `XmyShell` is **NOT** a Bash replacement. It's a Python‑native environment for those who want Python's power at the command line.
134
+
135
+ ## Usage
136
+
137
+ Start `XmyShell` by running the main module. Commands that are not built-in are passed to `/bin/sh` (or the system shell) for execution.
138
+ ```bash
139
+ $ xmyshell
140
+ XmyShell 0.1.0
141
+
142
+ ```
@@ -0,0 +1,132 @@
1
+ # XmyShell
2
+
3
+ **`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.
4
+
5
+ ## Features
6
+
7
+ ### Command Line Features
8
+
9
+ - Persistent Python namespace across commands (variables, imports, functions)
10
+ - Expand inline Python expressions within `{}`, using independent namespace.
11
+ ```
12
+ ❯ mkdir {" ".join(f"test{i}" for i in range(10))}
13
+ ❯ ls
14
+ test0 test1 test2 test3 test4 test5 test6 test7 test8 test9
15
+ ```
16
+
17
+ - Evaluate and print Python expressions with `print`
18
+ ```
19
+ ❯ print 1 + 1
20
+ 2
21
+ ```
22
+
23
+ - Execute Python statements with `pyexec`
24
+ ```
25
+ ❯ pyexec files = [f for f in os.listdir('.') if f.endswith('.py')]
26
+ ❯ print len(files)
27
+ 3
28
+ ```
29
+
30
+ - Capture command output into a Python variable with `=>`.
31
+ ```
32
+ ❯ which python => path
33
+ ❯ print path
34
+ /usr/bin/python
35
+ ❯ cd {dirname(path)}
36
+ ❯ pwd
37
+ /usr/bin
38
+ ```
39
+
40
+ - Redirect the output of Python commands (`print`, `pyexec`) with `|>`
41
+ ```
42
+ ❯ print "\n".join(str(i) for i in range(100)) |> grep 42 => result
43
+ ❯ print result
44
+ 42
45
+ ```
46
+
47
+ - Built-in `source` command to run python scripts.
48
+ ```
49
+ ❯ which python
50
+ /usr/bin/python
51
+ ❯ source .venv/bin/activate_this.py
52
+ ❯ which python
53
+ /tmp/test/.venv/bin/python
54
+ ```
55
+
56
+ - Built-in `export` command.
57
+ ```
58
+ ❯ pyexec foo = "foo"
59
+ ❯ export ENV_VAR={foo}bar
60
+ ❯ print ENV_VAR
61
+ foobar
62
+ ```
63
+
64
+ - Built-in `import` command.
65
+ ```
66
+ ❯ import numpy as np
67
+ ❯ from math import *
68
+ ```
69
+
70
+ - Reload with `reload` command.
71
+ ```
72
+ ❯ reload
73
+ ```
74
+
75
+ - Syntax highlighting via `prompt_toolkit`
76
+ - Powerful auto-completion, history search, and automatic bracket/quote pairing
77
+ - Startup configuration: `~/.xmyshell/config.py` loaded at launch
78
+ - Cross-platform (Windows, Linux, macOS)
79
+
80
+ ### Built-in Helper Functions
81
+
82
+ - `getlogin()`
83
+ Returns the current username.
84
+
85
+ - `getcwd()`
86
+ Returns the absolute path of the current working directory.
87
+
88
+ - `dirname(path)`
89
+ Returns the parent directory of a path.
90
+
91
+ - `basename(path)`
92
+ Returns the final component of a path.
93
+
94
+ ### Reserved global varibles
95
+ - `exit_code`
96
+ The exit code of the last command.
97
+
98
+ - `exec_duration`
99
+ The duration which last command took.
100
+
101
+ ### Keyboard Shortcuts
102
+ - `↑↓` -> Navigate through command history.
103
+ - `→` -> Apply selected history entry to the prompt.
104
+ - `Ctrl+R` -> Reverse incremental searching (history).
105
+ - `Ctrl+D` -> Exit XmyShell.
106
+ - Auto bracket/parenthesis/quote pairing
107
+
108
+
109
+ ## Limitations
110
+
111
+ **XmyShell** is Python‑first. This brings power, but also intentional trade‑offs.
112
+
113
+ - **No `source` for shell scripts** — `source` executes Python files via `runpy.run_path()`. Shell scripts (e.g., `venv/bin/activate`) won't work; use `activate_this.py` instead.
114
+
115
+ - **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.
116
+
117
+ - **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.
118
+
119
+ - **No pipelines between built‑in commands** — `print` and `pyexec` do not support `|`. Use Python variables to pass data.
120
+
121
+ - **External command overhead** — Each subprocess spawns with minor delays.
122
+
123
+ **Why?** `XmyShell` is **NOT** a Bash replacement. It's a Python‑native environment for those who want Python's power at the command line.
124
+
125
+ ## Usage
126
+
127
+ Start `XmyShell` by running the main module. Commands that are not built-in are passed to `/bin/sh` (or the system shell) for execution.
128
+ ```bash
129
+ $ xmyshell
130
+ XmyShell 0.1.0
131
+
132
+ ```
@@ -0,0 +1,19 @@
1
+ [project]
2
+ name = "xmyshell"
3
+ version = "0.1.0"
4
+ description = "XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "prompt-toolkit>=3.0.53",
9
+ ]
10
+
11
+ [tool.setuptools.packages.find]
12
+ where = ["."]
13
+ include = ["xmyshell*"]
14
+
15
+ [project.scripts]
16
+ xmyshell = "xmyshell.__main__:main"
17
+
18
+ [tool.setuptools.package-data]
19
+ "xmyshell" = ["data/*.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from .main import xmyshell_main
2
+ from .meta import NAME, VERSION, AUTHOR, EMAIL
3
+
4
+ __title__ = NAME
5
+ __version__ = VERSION
6
+ __author__ = AUTHOR
7
+ __author_email__ = EMAIL
@@ -0,0 +1,12 @@
1
+ import sys
2
+
3
+ def main() -> None:
4
+ if "--version" in sys.argv:
5
+ from .meta import WELCOME_MESSAGE
6
+ print(WELCOME_MESSAGE)
7
+ elif "--help" in sys.argv:
8
+ from .meta import HELP_MESSAGE
9
+ print(HELP_MESSAGE)
10
+ else:
11
+ from .main import xmyshell_main
12
+ xmyshell_main()