Terminal: Das prompt, dprompt and dbanner (0.9.1)
build / build (push) Successful in 38m26s

- das-shell 0.1.0: the Das two-line bash prompt by default (replaces the
  PS1 of Void's skel .bashrc once), dprompt (Textual prompt builder with
  presets and live preview) and dbanner (SSH login banner editor: canvas
  tools, fields with values, widgets, das-banner service for cached ones,
  Das OS logo and tryzub pictures). Python tests in make test.
- das-server 0.3.0 depends on das-shell; the server installer mentions
  dprompt and dbanner; the desktop image includes it.
- run-qemu.sh forwards the guest's SSH to localhost:2222.
- Hardware fixes: Ventoy menu icon, boot menu titles "Das OS <version>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
das
2026-10-21 09:17:10 +03:00
co-authored by Claude Opus 5.5
parent 66ea614e0d
commit a2bffc7fe9
72 changed files with 5506 additions and 23 deletions
@@ -0,0 +1,86 @@
import datetime
import os
import shutil
import subprocess
import unittest
from tests.common import FILES, SCRATCH
from das_shell import prompt # noqa: E402
NOW = datetime.datetime(2026, 10, 21, 8, 12)
def text(design, **state):
return prompt.preview_text(design, prompt.sample_state(now=NOW, **state))
class PresetTest(unittest.TestCase):
def test_presets_load(self):
names = [n for n, _ in prompt.list_presets()]
self.assertEqual(names[0], "das")
self.assertTrue({"das", "das-git", "classic", "minimal", "server"} <= set(names))
def test_das_matches_the_authors_prompt(self):
d = prompt.load_preset("das")
self.assertEqual(text(d), "┌─[das@dasos]─[2026-10-21]─[08:12]─[~/Projects/web]\n└─╼ $ ")
self.assertEqual(text(d, rc=1), "┌─[✗]─[das@dasos]─[2026-10-21]─[08:12]─[~/Projects/web]\n└─╼ $ ")
self.assertEqual(text(d, root=True), "┌─[root@dasos]─[2026-10-21]─[08:12]─[/etc/sv]\n└─╼ # ")
def test_classic_is_void(self):
self.assertEqual(text(prompt.load_preset("classic")), "[das@dasos web]$ ")
def test_hidden_parts_take_their_separator(self):
d = prompt.load_preset("das-git")
self.assertNotIn("──", text(d))
self.assertIn("─[main*]─[.venv]─[jobs:2]", text(d, git="main*", venv=".venv", jobs=2))
def test_unknown_segments_are_dropped(self):
d = prompt.normalize({"segments": [{"type": "nope"}, {"type": "cwd"}]})
self.assertEqual([s["type"] for s in d["segments"]], ["cwd"])
@unittest.skipUnless(shutil.which("bash"), "needs bash")
class BashTest(unittest.TestCase):
"""The generated script in a real bash, after Void's skel .bashrc."""
def run_prompt(self, preset, before="true", term="xterm-256color"):
path = os.path.join(SCRATCH, preset + ".sh")
with open(path, "w", encoding="utf-8") as f:
f.write(prompt.script(prompt.load_preset(preset)))
code = (f". {FILES}/prompt-lib.sh; . {path}; PS1='[\\u@\\h \\W]\\$ '; "
f"{before}; __das_prompt_hook; printf '%s' \"${{PS1@P}}\"")
out = subprocess.run(["bash", "--norc", "--noprofile", "-c", code], capture_output=True, text=True,
env=dict(os.environ, TERM=term, HOME="/home/das"), cwd="/").stdout
for seq in ("\x01", "\x02"):
out = out.replace(seq, "")
import re
return re.sub(r"\x1b\[[0-9;]*m|\x1b\][^\a]*\a", "", out)
def test_script_is_valid(self):
for name, _ in prompt.list_presets():
path = os.path.join(SCRATCH, name + ".sh")
with open(path, "w", encoding="utf-8") as f:
f.write(prompt.script(prompt.load_preset(name)))
subprocess.run(["bash", "-n", path], check=True)
def test_skel_ps1_is_replaced(self):
out = self.run_prompt("das")
self.assertTrue(out.startswith("┌─["), out)
self.assertNotIn("[✗]", out)
def test_error_mark(self):
self.assertIn("┌─[✗]─[", self.run_prompt("das", "false"))
def test_console_glyphs(self):
out = self.run_prompt("das", "false", term="linux")
self.assertIn("[x]", out)
self.assertIn("└─> ", out)
def test_plain_terminal(self):
out = self.run_prompt("das", term="dumb")
self.assertTrue(out.startswith("┌─["), out)
if __name__ == "__main__":
unittest.main()