From 6eb60868236df98d3a6e33b9162d0d4e5a4d2651 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Fri, 12 Jan 2024 19:32:25 -0800 Subject: [PATCH] Show last command and running commands in title with shell_integration (#11532) Closes #10260 I'm not 100% convinced about the star thing for running commands because on short commands it makes the title jitter. Signed-off-by: Alex Saveau --- crates/nu-cli/src/repl.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index e1c814a48c..ea0ebef7e5 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -549,6 +549,26 @@ pub fn evaluate_repl( } } + if shell_integration { + if let Some(cwd) = stack.get_env_var(engine_state, "PWD") { + let path = cwd.as_string()?; + + // Try to abbreviate string for windows title + let maybe_abbrev_path = if let Some(p) = nu_path::home_dir() { + path.replace(&p.as_path().display().to_string(), "~") + } else { + path + }; + let binary_name = s.split_whitespace().next(); + + if let Some(binary_name) = binary_name { + run_ansi_sequence(&format!( + "\x1b]2;{maybe_abbrev_path}> {binary_name}\x07" + ))?; + } + } + } + eval_source( engine_state, stack,