Added prompt escape code expansion flag to echo, -p

Added non-formatted runtime to prompt escape codes

Added prompt escape code that expands to the output of a shell function

Reworked internal logic for termios control
This commit is contained in:
2026-01-29 03:46:35 -05:00
parent 70f0e849ba
commit a4f48abd49
10 changed files with 381 additions and 178 deletions

View File

@@ -11,17 +11,19 @@ use crate::{
/// Initialize the line editor
fn get_prompt() -> ShResult<String> {
let Ok(prompt) = env::var("PS1") else {
// prompt expands to:
// default prompt expands to:
//
// username@hostname
// short/path/to/pwd/
// $ _
let default =
"\\n\\e[1;0m\\u\\e[1;36m@\\e[1;31m\\h\\n\\e[1;36m\\W\\e[1;32m/\\n\\e[1;32m\\$\\e[0m ";
"\\e[0m\\n\\e[1;0m\\u\\e[1;36m@\\e[1;31m\\h\\n\\e[1;36m\\W\\e[1;32m/\\n\\e[1;32m\\$\\e[0m ";
return expand_prompt(default);
};
let sanitized = format!("\\e[0m{prompt}");
flog!(DEBUG, "Using prompt: {}", sanitized.replace("\n", "\\n"));
expand_prompt(&prompt)
expand_prompt(&sanitized)
}
pub fn readline(edit_mode: FernEditMode, initial: Option<&str>) -> ShResult<String> {