xmyshell 0.2.17__tar.gz → 0.2.19__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.2.17/xmyshell.egg-info → xmyshell-0.2.19}/PKG-INFO +10 -1
- {xmyshell-0.2.17 → xmyshell-0.2.19}/README.md +9 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/pyproject.toml +1 -1
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/environment.py +1 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/kernel.py +1 -1
- xmyshell-0.2.19/xmyshell/meta.py +85 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19/xmyshell.egg-info}/PKG-INFO +10 -1
- xmyshell-0.2.17/xmyshell/meta.py +0 -71
- {xmyshell-0.2.17 → xmyshell-0.2.19}/LICENSE +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/setup.cfg +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/__init__.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/__main__.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/completer.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/data/commands.json +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/init.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/injection.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/keybindings.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/main.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/stubs/__init__.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/stubs/__init__.pyi +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/stubs/py.typed +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/themes.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/update.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell/utils.py +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell.egg-info/SOURCES.txt +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell.egg-info/dependency_links.txt +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell.egg-info/entry_points.txt +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell.egg-info/requires.txt +0 -0
- {xmyshell-0.2.17 → xmyshell-0.2.19}/xmyshell.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmyshell
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -163,6 +163,15 @@ The exit code of the last command.
|
|
|
163
163
|
- `exec_duration`
|
|
164
164
|
The duration which last command took.
|
|
165
165
|
|
|
166
|
+
- `last_error`
|
|
167
|
+
The error raised from last Python operation (if exists).
|
|
168
|
+
|
|
169
|
+
- `last_traceback`
|
|
170
|
+
The traceback of last Python operation (if exists).
|
|
171
|
+
|
|
172
|
+
- `ans`
|
|
173
|
+
The result from last print command.
|
|
174
|
+
|
|
166
175
|
- `SHOW_WELCOME`
|
|
167
176
|
Toggle whether to show welcome message when staring.
|
|
168
177
|
|
|
@@ -153,6 +153,15 @@ The exit code of the last command.
|
|
|
153
153
|
- `exec_duration`
|
|
154
154
|
The duration which last command took.
|
|
155
155
|
|
|
156
|
+
- `last_error`
|
|
157
|
+
The error raised from last Python operation (if exists).
|
|
158
|
+
|
|
159
|
+
- `last_traceback`
|
|
160
|
+
The traceback of last Python operation (if exists).
|
|
161
|
+
|
|
162
|
+
- `ans`
|
|
163
|
+
The result from last print command.
|
|
164
|
+
|
|
156
165
|
- `SHOW_WELCOME`
|
|
157
166
|
Toggle whether to show welcome message when staring.
|
|
158
167
|
|
|
@@ -189,10 +189,10 @@ def xmyshell_raw_command(cmd_line: str) -> int | None:
|
|
|
189
189
|
result = eval(expr, dict(os.environ), namespace)
|
|
190
190
|
print(result)
|
|
191
191
|
namespace["last_error"] = None
|
|
192
|
+
namespace["ans"] = result
|
|
192
193
|
return 0
|
|
193
194
|
except Exception as e:
|
|
194
195
|
import traceback
|
|
195
|
-
|
|
196
196
|
namespace["last_error"] = e
|
|
197
197
|
namespace["last_traceback"] = traceback.format_exc()
|
|
198
198
|
pyerror(f"{type(e).__name__}: {e}")
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
|
|
3
|
+
# ANSI color codes
|
|
4
|
+
RESET = "\033[0m"
|
|
5
|
+
BOLD = "\033[1m"
|
|
6
|
+
NOBOLD = "\033[22m"
|
|
7
|
+
CYAN = "\033[36m"
|
|
8
|
+
GREEN = "\033[92m"
|
|
9
|
+
YELLOW = "\033[93m"
|
|
10
|
+
BLUE = "\033[94m"
|
|
11
|
+
MAGENTA = "\033[95m"
|
|
12
|
+
|
|
13
|
+
NAME = "xmyshell"
|
|
14
|
+
DISPLAY_NAME = "XmyShell"
|
|
15
|
+
VERSION = version(NAME)
|
|
16
|
+
AUTHOR = "CaptainSuo"
|
|
17
|
+
EMAIL = "captainsuo@outlook.com"
|
|
18
|
+
WELCOME_MESSAGE = f"""{BOLD}{BLUE}{DISPLAY_NAME} {CYAN}{VERSION}{RESET}"""
|
|
19
|
+
|
|
20
|
+
HELP_MESSAGE = f"""{BOLD}{CYAN}
|
|
21
|
+
███╗ ███╗ ███╗ ███╗ ██╗ ██╗ ███████╗ ██╗ ██╗ ███████╗ ██╗ ██╗
|
|
22
|
+
╚═██╗██╔═╝ ████╗ ████║ ╚██╗ ██╔╝ ██╔════╝ ██║ ██║ ██╔════╝ ██║ ██║
|
|
23
|
+
╚███╔╝ ██╔████╔██║ ╚████╔╝ ███████╗ ████████║ ██████╗ ██║ ██║
|
|
24
|
+
██╔██╗ ██║╚██╔╝██║ ╚██╔╝ ╚════██║ ██╔═══██║ ██╔═══╝ ██║ ██║
|
|
25
|
+
███╔╝ ███╗ ██║ ╚═╝ ██║ ██║ ███████║ ██║ ██║ ███████╗ ███████╗ ███████╗
|
|
26
|
+
╚══╝ ╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚══════╝ ╚══════╝ ╚══════╝
|
|
27
|
+
{RESET}
|
|
28
|
+
{WELCOME_MESSAGE}
|
|
29
|
+
|
|
30
|
+
{BOLD}{YELLOW}Built-in Commands{BOLD}{CYAN}
|
|
31
|
+
{BOLD}{GREEN}help{CYAN} {NOBOLD}Show help documents.
|
|
32
|
+
{BOLD}{GREEN}print{CYAN} <expr> {NOBOLD}Evaluate and print a Python expression.
|
|
33
|
+
{BOLD}{GREEN}pyexec{CYAN} <stmt> {NOBOLD}Execute a Python statement.
|
|
34
|
+
{BOLD}{GREEN}source{CYAN} <file.py> {NOBOLD}Run a Python script in the current namespace.
|
|
35
|
+
{BOLD}{GREEN}export{CYAN} <NAME>=<value> {NOBOLD}Set an environment variable (supports {{expr}}).
|
|
36
|
+
{BOLD}{GREEN}import{CYAN} <module> [as <alt>] {NOBOLD}Import a Python module.
|
|
37
|
+
{BOLD}{GREEN}from{CYAN} <module> import <names> {NOBOLD}Import names from a module.
|
|
38
|
+
{BOLD}{GREEN}reload{CYAN} {NOBOLD}Reload environment.
|
|
39
|
+
{BOLD}{GREEN}update{CYAN} [<version>] {NOBOLD}Update xmyshell.
|
|
40
|
+
{BOLD}{GREEN}cd{CYAN} <dir> {NOBOLD}Change directory (supports {{expr}}).
|
|
41
|
+
{BOLD}{GREEN}pwd{CYAN} {NOBOLD}Print working directory.
|
|
42
|
+
{BOLD}{GREEN}clear{CYAN} {NOBOLD}Clear the terminal screen.
|
|
43
|
+
{BOLD}{GREEN}alias{CYAN} altname=<cmd> {NOBOLD}Create an alias command.
|
|
44
|
+
{BOLD}{GREEN}unalias{CYAN} altname {NOBOLD}Remove an alias command.
|
|
45
|
+
{BOLD}{GREEN}exit{CYAN} {NOBOLD}Exit XmyShell.
|
|
46
|
+
|
|
47
|
+
{BOLD}{YELLOW}Inline Python{NOBOLD}{CYAN}
|
|
48
|
+
Use {{expression}} anywhere in a command to expand its result.
|
|
49
|
+
{BOLD}{MAGENTA}Example{NOBOLD}{CYAN} mkdir {{" ".join(f"test{{i}}" for i in range(3))}}
|
|
50
|
+
Escape braces as {{{{ and }}}}.
|
|
51
|
+
|
|
52
|
+
{BOLD}{YELLOW}IO{NOBOLD}{CYAN}
|
|
53
|
+
Append => variable to a command to capture its output while still
|
|
54
|
+
displaying it.
|
|
55
|
+
{BOLD}{MAGENTA}Example{NOBOLD}{CYAN} which python => path
|
|
56
|
+
Redirect the output of Python commands (print, pyexec) with |>
|
|
57
|
+
{BOLD}{MAGENTA}Example{NOBOLD}{CYAN} print "\\n".join(str(i) for i in range(100)) |> grep 42
|
|
58
|
+
|
|
59
|
+
{BOLD}{YELLOW}Helper Functions{NOBOLD}{CYAN}
|
|
60
|
+
{BLUE}getlogin{CYAN}() current username
|
|
61
|
+
{BLUE}getcwd{CYAN}() current working directory
|
|
62
|
+
{BLUE}dirname{CYAN}(p) parent directory of path
|
|
63
|
+
{BLUE}basename{CYAN}(p) final component of path
|
|
64
|
+
{BLUE}cat{CYAN}(file) Shortcut for open(file).read().
|
|
65
|
+
{BLUE}alias{CYAN}(altname, cmd) Same as the command.
|
|
66
|
+
{BLUE}unalias{CYAN}(altname) Same as the command.
|
|
67
|
+
|
|
68
|
+
{BOLD}{YELLOW}Built-in variables{NOBOLD}{CYAN}
|
|
69
|
+
{BLUE}exit_code{CYAN} The exit code of the last command.
|
|
70
|
+
{BLUE}exec_duration{CYAN} The duration which last command took.
|
|
71
|
+
{BLUE}last_error{CYAN} The error raised from last Python operation (if exists).
|
|
72
|
+
{BLUE}last_traceback{CYAN} The traceback of last Python operation (if exists).
|
|
73
|
+
{BLUE}ans{CYAN} The result from last print command.
|
|
74
|
+
{BLUE}HOME_DIR{CYAN} The home directory, similar to "~".
|
|
75
|
+
{BLUE}PROFILE{CYAN} The path of config file.
|
|
76
|
+
{BLUE}SHOW_WELCOME{CYAN} Toggle whether to show welcome message.
|
|
77
|
+
{BLUE}SHELL_CMD{CYAN} Shell command line prefix, e.g. ["cmd", "/c"]
|
|
78
|
+
|
|
79
|
+
{BOLD}{YELLOW}Keyboard Shortcuts{NOBOLD}{CYAN}
|
|
80
|
+
{MAGENTA}↑↓ {CYAN}Navigate through command history.
|
|
81
|
+
{MAGENTA}→ {CYAN}Apply selected history entry to the prompt.
|
|
82
|
+
{MAGENTA}Ctrl+R {CYAN}Reverse incremental searching (history).
|
|
83
|
+
{MAGENTA}Ctrl+Z {CYAN}Undo.
|
|
84
|
+
{MAGENTA}Ctrl+Y {CYAN}Redo.
|
|
85
|
+
{MAGENTA}Ctrl+D {CYAN}Exit XmyShell.{RESET}"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xmyshell
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -163,6 +163,15 @@ The exit code of the last command.
|
|
|
163
163
|
- `exec_duration`
|
|
164
164
|
The duration which last command took.
|
|
165
165
|
|
|
166
|
+
- `last_error`
|
|
167
|
+
The error raised from last Python operation (if exists).
|
|
168
|
+
|
|
169
|
+
- `last_traceback`
|
|
170
|
+
The traceback of last Python operation (if exists).
|
|
171
|
+
|
|
172
|
+
- `ans`
|
|
173
|
+
The result from last print command.
|
|
174
|
+
|
|
166
175
|
- `SHOW_WELCOME`
|
|
167
176
|
Toggle whether to show welcome message when staring.
|
|
168
177
|
|
xmyshell-0.2.17/xmyshell/meta.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from importlib.metadata import version
|
|
2
|
-
|
|
3
|
-
NAME = "xmyshell"
|
|
4
|
-
DISPLAY_NAME = "XmyShell"
|
|
5
|
-
VERSION = version(NAME)
|
|
6
|
-
AUTHOR = "CaptainSuo"
|
|
7
|
-
EMAIL = "captainsuo@outlook.com"
|
|
8
|
-
WELCOME_MESSAGE = f"""{DISPLAY_NAME} {VERSION}"""
|
|
9
|
-
HELP_MESSAGE = f"""\033[1;36m
|
|
10
|
-
███╗ ███╗ ███╗ ███╗ ██╗ ██╗ ███████╗ ██╗ ██╗ ███████╗ ██╗ ██╗
|
|
11
|
-
╚═██╗██╔═╝ ████╗ ████║ ╚██╗ ██╔╝ ██╔════╝ ██║ ██║ ██╔════╝ ██║ ██║
|
|
12
|
-
╚███╔╝ ██╔████╔██║ ╚████╔╝ ███████╗ ████████║ ██████╗ ██║ ██║
|
|
13
|
-
██╔██╗ ██║╚██╔╝██║ ╚██╔╝ ╚════██║ ██╔═══██║ ██╔═══╝ ██║ ██║
|
|
14
|
-
███╔╝ ███╗ ██║ ╚═╝ ██║ ██║ ███████║ ██║ ██║ ███████╗ ███████╗ ███████╗
|
|
15
|
-
╚══╝ ╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚══════╝ ╚══════╝ ╚══════╝
|
|
16
|
-
\033[0m
|
|
17
|
-
{WELCOME_MESSAGE}
|
|
18
|
-
|
|
19
|
-
Built-in Commands:
|
|
20
|
-
help Show help documents.
|
|
21
|
-
print <expr> Evaluate and print a Python expression.
|
|
22
|
-
pyexec <stmt> Execute a Python statement (e.g. pyexec x = 1).
|
|
23
|
-
source <file.py> Run a Python script in the current namespace.
|
|
24
|
-
export <NAME>=<value> Set an environment variable (supports {{expr}}).
|
|
25
|
-
import <module> [as <alt>] Import a Python module.
|
|
26
|
-
from <module> import <names> Import names from a module.
|
|
27
|
-
reload Reload environment (e.g. exit virtualenv).
|
|
28
|
-
update [<version>] Update xmyshell (optionally to a specific version).
|
|
29
|
-
cd <dir> Change directory (supports {{expr}}).
|
|
30
|
-
pwd Print working directory.
|
|
31
|
-
clear Clear the terminal screen.
|
|
32
|
-
alias altname=<cmd> Create an alias command.
|
|
33
|
-
unalias altname Remove an alias command.
|
|
34
|
-
exit Exit XmyShell.
|
|
35
|
-
|
|
36
|
-
Inline Python:
|
|
37
|
-
Use {{expression}} anywhere in a command to expand its result.
|
|
38
|
-
Example: mkdir {{" ".join(f"test{{i}}" for i in range(3))}}
|
|
39
|
-
Escape braces as {{{{ and }}}}.
|
|
40
|
-
|
|
41
|
-
IO:
|
|
42
|
-
Append => variable to a command to capture its output while still
|
|
43
|
-
displaying it.
|
|
44
|
-
Example: which python => path
|
|
45
|
-
Redirect the output of Python commands (print, pyexec) with |>
|
|
46
|
-
Example: print "\\n".join(str(i) for i in range(100)) |> grep 42
|
|
47
|
-
|
|
48
|
-
Helper Functions:
|
|
49
|
-
getlogin() - current username
|
|
50
|
-
getcwd() - current working directory
|
|
51
|
-
dirname(p) - parent directory of path
|
|
52
|
-
basename(p) - final component of path
|
|
53
|
-
cat(file) - Shortcut for open(file).read().
|
|
54
|
-
alias(altname, cmd) - Same as the command.
|
|
55
|
-
unalias(altname) - Same as the command.
|
|
56
|
-
|
|
57
|
-
Built-in variables:
|
|
58
|
-
exit_code - The exit code of the last command.
|
|
59
|
-
exec_duration - The duration which last command took.
|
|
60
|
-
HOME_DIR - The home directory, similar to "~".
|
|
61
|
-
PROFILE - The path of config file.
|
|
62
|
-
SHOW_WELCOME - Toggle whether to show welcome message.
|
|
63
|
-
SHELL_CMD - Shell command line prefix, e.g. ["cmd", "/c"]
|
|
64
|
-
|
|
65
|
-
Keyboard Shortcuts:
|
|
66
|
-
↑↓ - Navigate through command history.
|
|
67
|
-
→ - Apply selected history entry to the prompt.
|
|
68
|
-
Ctrl+R - Reverse incremental searching (history).
|
|
69
|
-
Ctrl+Z - Undo.
|
|
70
|
-
Ctrl+Y - Redo.
|
|
71
|
-
Ctrl+D - Exit XmyShell."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|