xmyshell 0.2.1__tar.gz → 0.2.3__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.
Files changed (25) hide show
  1. {xmyshell-0.2.1/xmyshell.egg-info → xmyshell-0.2.3}/PKG-INFO +1 -1
  2. {xmyshell-0.2.1 → xmyshell-0.2.3}/pyproject.toml +1 -1
  3. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/completer.py +29 -19
  4. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/init.py +2 -1
  5. {xmyshell-0.2.1 → xmyshell-0.2.3/xmyshell.egg-info}/PKG-INFO +1 -1
  6. {xmyshell-0.2.1 → xmyshell-0.2.3}/LICENSE +0 -0
  7. {xmyshell-0.2.1 → xmyshell-0.2.3}/README.md +0 -0
  8. {xmyshell-0.2.1 → xmyshell-0.2.3}/setup.cfg +0 -0
  9. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/__init__.py +0 -0
  10. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/__main__.py +0 -0
  11. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/data/commands.json +0 -0
  12. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/environment.py +0 -0
  13. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/kernel.py +0 -0
  14. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/keybindings.py +0 -0
  15. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/lexer.py +0 -0
  16. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/main.py +0 -0
  17. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/meta.py +0 -0
  18. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/themes.py +0 -0
  19. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/update.py +0 -0
  20. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell/utils.py +0 -0
  21. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell.egg-info/SOURCES.txt +0 -0
  22. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell.egg-info/dependency_links.txt +0 -0
  23. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell.egg-info/entry_points.txt +0 -0
  24. {xmyshell-0.2.1 → xmyshell-0.2.3}/xmyshell.egg-info/requires.txt +0 -0
  25. {xmyshell-0.2.1 → xmyshell-0.2.3}/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.1
3
+ Version: 0.2.3
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xmyshell"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -16,7 +16,8 @@ MAX_DISPLAY_LEN = 24
16
16
  MAX_META_LEN = 12
17
17
 
18
18
  BUILTINS = ("cd", "cp", "cat", "echo", "exit", "import", "ls", "print", "pyexec", "pwd", "source",
19
- "clear", "grep", "find", "from", "mkdir", "rm", "reload", "mv", "help", "alias", "update")
19
+ "clear", "grep", "find", "from", "mkdir", "rm", "reload", "mv", "help",
20
+ "update", "alias", "unalias")
20
21
 
21
22
  COMMON = (
22
23
  "python", "python3", "pip", "pip3", "git", "conda", "uv",
@@ -312,6 +313,28 @@ class ShellCompleter(Completer):
312
313
  display_meta="flag",
313
314
  )
314
315
 
316
+ def _command_completion(self, text):
317
+ for cmd in self._get_commands():
318
+ if cmd in aliases: continue
319
+ if cmd.startswith(text):
320
+ meta = "command" if cmd in BUILTINS else "program"
321
+ yield Completion(
322
+ cmd,
323
+ start_position=-len(text),
324
+ display=truncate(cmd, MAX_DISPLAY_LEN),
325
+ display_meta=meta,
326
+ )
327
+
328
+ def _alias_completion(self, text):
329
+ for alias in aliases.keys():
330
+ if alias.startswith(text):
331
+ yield Completion(
332
+ alias,
333
+ start_position=-len(text),
334
+ display=truncate(alias, MAX_DISPLAY_LEN),
335
+ display_meta="alias",
336
+ )
337
+
315
338
  def get_completions(self, document: Document, complete_event):
316
339
  text = document.text_before_cursor
317
340
  if "=>" in text: return
@@ -328,24 +351,8 @@ class ShellCompleter(Completer):
328
351
  if " " not in lstripped:
329
352
  if len(lstripped) < 1:
330
353
  return
331
- for alias in aliases.keys():
332
- if alias.startswith(lstripped):
333
- yield Completion(
334
- alias,
335
- start_position=-len(lstripped),
336
- display=truncate(alias, MAX_DISPLAY_LEN),
337
- display_meta="alias",
338
- )
339
- for cmd in self._get_commands():
340
- if cmd in aliases: return
341
- if cmd.startswith(lstripped):
342
- meta = "command" if cmd in BUILTINS else "program"
343
- yield Completion(
344
- cmd,
345
- start_position=-len(lstripped),
346
- display=truncate(cmd, MAX_DISPLAY_LEN),
347
- display_meta=meta,
348
- )
354
+ yield from self._alias_completion(lstripped)
355
+ yield from self._command_completion(lstripped)
349
356
 
350
357
  # special built-ins
351
358
  parts = lstripped.split()
@@ -355,6 +362,9 @@ class ShellCompleter(Completer):
355
362
  param_text = lstripped[len(cmd):].lstrip()
356
363
  yield from self._python_completion(param_text)
357
364
  return
365
+ if cmd == "unalias":
366
+ param_text = lstripped[len(cmd):].lstrip()
367
+ yield from self._alias_completion(param_text)
358
368
  if cmd == "from":
359
369
  if not lstripped.endswith(parts[-1]):
360
370
  parts.append("")
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  import sys
3
- from .environment import load_init_namespace, init_environ
3
+ from .environment import load_init_namespace, init_environ, aliases
4
4
  from .themes import load_theme, THEME_DEFAULT
5
5
  from .completer import completer_init
6
6
  from .utils import pywarning
@@ -34,4 +34,5 @@ def xmyshell_init() -> None:
34
34
  def xmyshell_reload() -> None:
35
35
  os.environ.clear()
36
36
  os.environ.update(init_environ)
37
+ aliases.clear()
37
38
  xmyshell_load()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xmyshell
3
- Version: 0.2.1
3
+ Version: 0.2.3
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
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