Skip to content

Commit 96b234c

Browse files
committed
Add fixes for target-shell prompt
And some miscellaneous fixes of typing and consistency
1 parent 12306a3 commit 96b234c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

dissect/target/tools/shell.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from datetime import datetime, timedelta, timezone
2222
from typing import Any, BinaryIO, Callable, Iterator, TextIO
2323

24-
from dissect.cstruct import hexdump
2524
from flow.record import RecordOutput
2625

26+
from dissect.cstruct import hexdump
2727
from dissect.target.exceptions import (
2828
PluginError,
2929
RegistryError,
@@ -304,11 +304,11 @@ def _exec_(argparts: list[str], stdout: TextIO) -> bool:
304304
no_cyber = cmdfunc.__func__ in (TargetCli.cmd_registry, TargetCli.cmd_enter)
305305
return self._exec(_exec_, command_args_str, no_cyber)
306306

307-
def do_man(self, line: str) -> bool:
307+
def do_man(self, line: str) -> None:
308308
"""alias for help"""
309-
return self.do_help(line)
309+
self.do_help(line)
310310

311-
def complete_man(self, *args) -> list[str]:
311+
def complete_man(self, *args: list[str]) -> list[str]:
312312
return cmd.Cmd.complete_help(self, *args)
313313

314314
def do_unalias(self, line: str) -> bool:
@@ -403,16 +403,14 @@ def __init__(self, target: Target):
403403
self.histfile = pathlib.Path(getattr(target._config, "HISTFILE", self.DEFAULT_HISTFILE)).expanduser()
404404

405405
# prompt format
406+
self.prompt_ps1 = "{BOLD_GREEN}{base}{RESET}:{BOLD_BLUE}{cwd}{RESET}$ "
406407
if ps1 := getattr(target._config, "PS1", None):
407408
if "{cwd}" in ps1 and "{base}" in ps1:
408409
self.prompt_ps1 = ps1
409410

410411
elif getattr(target._config, "NO_COLOR", None) or os.getenv("NO_COLOR"):
411412
self.prompt_ps1 = "{base}:{cwd}$ "
412413

413-
else:
414-
self.prompt_ps1 = "{BOLD_GREEN}{base}{RESET}:{BOLD_BLUE}{cwd}{RESET}$ "
415-
416414
super().__init__(self.target.props.get("cyber"))
417415

418416
def _get_targetrc_path(self) -> pathlib.Path:

0 commit comments

Comments
 (0)