diff --git a/README.md b/README.md index 42ba759..27bf8d2 100644 --- a/README.md +++ b/README.md @@ -148,5 +148,5 @@ daphne config.asgi:application -b 127.0.0.1 -p 8001 | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | DJANGO_ADMIN_SHELLX_SUPERUSER_ONLY | Allow only SuperUsers to access the admin shellx. | `boolean` | `True` | no | -| DJANGO_ADMIN_SHELLX_COMMAND | The default commands to use when opening the terminal. | `list[list[str]]` | [["./manage.py", "shell_plus"], ["./manage.py", "shell"], ["/bin/bash"]] | no | +| DJANGO_ADMIN_SHELLX_COMMANDS | The default commands to use when opening the terminal. | `list[list[str]]` | [["./manage.py", "shell_plus"], ["./manage.py", "shell"], ["/bin/bash"]] | no | | DJANGO_ADMIN_SHELLX_WS_PORT | The port to use for the websocket. | `int` | None | no | diff --git a/django_admin_shellx/consumers.py b/django_admin_shellx/consumers.py index b85139c..74196bd 100644 --- a/django_admin_shellx/consumers.py +++ b/django_admin_shellx/consumers.py @@ -136,13 +136,16 @@ def disconnect(self, code): def map_terminal_prompt(self, terminal_prompt): + if "reverse-i-search" in terminal_prompt or "I-search" in terminal_prompt: + return "DJWShell Search", None + command = None prompt = None # pattern >>> TerminalCommand.objects.all() match_1 = re.match(r">>> (.*)", terminal_prompt) # pattern In [2]: TerminalCommand.objects.all()' - match_2 = re.match(r"In \[\w\]: (.*)", terminal_prompt) + match_2 = re.match(r"In \[.*\]: (.*)", terminal_prompt) # pattern root@test-app-bf4fdfb6-726qh:/app# echo 'hello world' match_3 = re.match(r"^(\S+\s+[^$]+\$)\s+(.*)", terminal_prompt) # [adin@adin test]$ echo 'hello world' @@ -170,6 +173,9 @@ def map_terminal_prompt(self, terminal_prompt): def save_command_history(self, command): command, prompt = self.map_terminal_prompt(command) + if command == "DJWShell Search": + return + if not command: logging.warning("No command to save") return diff --git a/pyproject.toml b/pyproject.toml index 754d4fa..ba27c3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "django-admin-shellx" -version = "0.2.2" +version = "0.2.3" description = "A Django Admin Shell" authors = ["Adin Hodovic "] license = "MIT" diff --git a/tests/settings.py b/tests/settings.py index 794b770..0d76863 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -93,7 +93,7 @@ } DJANGO_ADMIN_SHELLX_SUPERUSER_ONLY = True -DJANGO_ADMIN_SHELLX_COMMAND = [ +DJANGO_ADMIN_SHELLX_COMMANDS = [ ["./manage.py", "shell_plus"], ["./manage.py", "shell"], ["/bin/bash"],