Files
lush/issues/21-prompt-redesign.md
Cormac Shannon 9e75175c79 Add issues #16–#23
#16 multiline shell commands
#17 _ scope (global vs local)
#18 path expansion (~)
#19 nested commands trigger prompt2
#20 simplify backtick return value
#21 prompt redesign
#22 implicit interactive commands (drop ! prefix)
#23 general cleanup and refactor
2026-03-04 23:28:11 +00:00

28 lines
964 B
Markdown

# 21 — Prompt redesign
**Status:** open
Reconsider the prompt system. Some observations:
## Functional prompts via metatables
Functional prompts can be achieved in pure Lua without special support:
```lua
_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 `_PROMPT2` somehow
- Add indentation (spaces/tabs) after prompt2 on the C side
- Accept it as-is (bash doesn't do this either)