feat: prompt REPL — emoji 🪟 + shell actif après la version
Le statut avant chaque invite affiche maintenant le shell-gateway courant (ex: ⚙ am v1.0.0 🪟 bash │ ...), mis à jour dynamiquement via 'shell <name>'. Vérifié en réel : bash → pwsh après switch.
This commit is contained in:
+12
-7
@@ -890,13 +890,18 @@ fn emoji(glyph: &str, style: &str, theme: &Theme, color: bool) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// One-line status shown before every prompt, with colored emojis:
|
/// One-line status shown before every prompt, with colored emojis:
|
||||||
/// ⚙ am v0.2.13 │ 🗂️ cwd │ 73 🤖 · 12 🌐 · 0 📊 │ ⚡ 97ms │ ⏲ 32s
|
/// ⚙ am v0.2.13 🪟 bash │ 🗂️ cwd │ 73 🤖 · 12 🌐 · 0 📊 │ ⚡ 97ms │ ⏲ 32s
|
||||||
/// The last parameter is the duration of the previous command (None before
|
/// `shell` is the active shell-gateway name (issue #44). The last parameter
|
||||||
/// the first one).
|
/// is the duration of the previous command (None before the first one).
|
||||||
fn print_status(app: &App, started: Instant, last: Option<Duration>) {
|
fn print_status(app: &App, started: Instant, last: Option<Duration>, shell: &str) {
|
||||||
let color = app.color();
|
let color = app.color();
|
||||||
let theme = app.theme();
|
let theme = app.theme();
|
||||||
let sep = dim(" │ ", theme, color);
|
let sep = dim(" │ ", theme, color);
|
||||||
|
let shell_part = format!(
|
||||||
|
"{} {}",
|
||||||
|
emoji("🪟", "cyan", theme, color),
|
||||||
|
dim(shell, theme, color)
|
||||||
|
);
|
||||||
let cwd = shorten_head(¤t_dir_string(), 30);
|
let cwd = shorten_head(¤t_dir_string(), 30);
|
||||||
let folder = format!(
|
let folder = format!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
@@ -931,7 +936,7 @@ fn print_status(app: &App, started: Instant, last: Option<Duration>) {
|
|||||||
color,
|
color,
|
||||||
);
|
);
|
||||||
println!(
|
println!(
|
||||||
"{}am v{}{sep}{folder}{sep}{counts}{sep}{last_part}{sep}{elapsed}",
|
"{}am v{}{sep}{shell_part}{sep}{folder}{sep}{counts}{sep}{last_part}{sep}{elapsed}",
|
||||||
dim(" ⚙ ", theme, color),
|
dim(" ⚙ ", theme, color),
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
);
|
);
|
||||||
@@ -1142,7 +1147,7 @@ fn run_with_editor(app: &App, session: &mut ShellSession, sid: &str) -> Result<i
|
|||||||
let mut first_read = true;
|
let mut first_read = true;
|
||||||
let mut theme: &'static crate::theme::Theme = app.theme();
|
let mut theme: &'static crate::theme::Theme = app.theme();
|
||||||
loop {
|
loop {
|
||||||
print_status(app, started, last_duration);
|
print_status(app, started, last_duration, &session.current.name);
|
||||||
let signal = match rl.read_line(&prompt) {
|
let signal = match rl.read_line(&prompt) {
|
||||||
Ok(signal) => signal,
|
Ok(signal) => signal,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -1231,7 +1236,7 @@ fn run_plain(app: &App, session: &mut ShellSession, sid: &str) -> Result<i32> {
|
|||||||
let mut last: Option<DataTable> = None;
|
let mut last: Option<DataTable> = None;
|
||||||
let mut last_duration: Option<Duration> = None;
|
let mut last_duration: Option<Duration> = None;
|
||||||
loop {
|
loop {
|
||||||
print_status(app, started, last_duration);
|
print_status(app, started, last_duration, &session.current.name);
|
||||||
eprint!("❯ ");
|
eprint!("❯ ");
|
||||||
std::io::stderr().flush().ok();
|
std::io::stderr().flush().ok();
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user