Skip to content

Commit fe32d50

Browse files
authored
Add fixes for target-shell prompt (#943)
1 parent bb9a488 commit fe32d50

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dissect/target/tools/shell.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,10 @@ def _exec_(argparts: list[str], stdout: TextIO) -> bool:
306306

307307
def do_man(self, line: str) -> bool:
308308
"""alias for help"""
309-
return self.do_help(line)
309+
self.do_help(line)
310+
return False
310311

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

314315
def do_unalias(self, line: str) -> bool:
@@ -403,16 +404,16 @@ def __init__(self, target: Target):
403404
self.histfile = pathlib.Path(getattr(target._config, "HISTFILE", self.DEFAULT_HISTFILE)).expanduser()
404405

405406
# prompt format
407+
self.prompt_ps1 = "{BOLD_GREEN}{base}{RESET}:{BOLD_BLUE}{cwd}{RESET}$ "
406408
if ps1 := getattr(target._config, "PS1", None):
407409
if "{cwd}" in ps1 and "{base}" in ps1:
408410
self.prompt_ps1 = ps1
411+
else:
412+
self.target.log.warning("{cwd} and {base} were not set inside PS1, using the default prompt")
409413

410414
elif getattr(target._config, "NO_COLOR", None) or os.getenv("NO_COLOR"):
411415
self.prompt_ps1 = "{base}:{cwd}$ "
412416

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

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

0 commit comments

Comments
 (0)