Revert the bespoke __prompt()/__prompt2() function mechanism from issue #09 and return to stock Lua's _PROMPT/_PROMPT2 globals (which already support dynamic prompts via __tostring metatables). Set default _PROMPT = "lush> " in doREPL if not already defined by config.
964 B
964 B
21 — Prompt redesign
Status: done
Reconsider the prompt system. Some observations:
Functional prompts via metatables
Functional prompts can be achieved in pure Lua without special support:
_PROMPT = setmetatable({}, { __tostring = function(self)
local user = os.getenv("USER") or os.getenv("USERNAME") or "user"
local cwd = os.getenv("PWD") or io.popen("pwd"):read("*l") or "?"
return string.format("%s:%s$ ", user, cwd)
end })
This suggests our bespoke prompt implementation (issue #09) may be overengineered. A template-based approach or just documenting the metatable trick might suffice.
Prompt2 depth
Prompt2 is rigid — opening deeper and deeper blocks results in a prompt at the same level. Bash doesn't do depth indication either, so maybe this is fine. Options:
- Pass depth into
_PROMPT2somehow - Add indentation (spaces/tabs) after prompt2 on the C side
- Accept it as-is (bash doesn't do this either)