diff --git a/crates/deno_task_shell/src/shell/types.rs b/crates/deno_task_shell/src/shell/types.rs index aa4eb95..28c674a 100644 --- a/crates/deno_task_shell/src/shell/types.rs +++ b/crates/deno_task_shell/src/shell/types.rs @@ -58,6 +58,12 @@ pub struct ShellState { pub fn set_terminal_title(title: &str) { // Only set title if we're in an interactive terminal session if std::io::stdout().is_terminal() { + let title = title.replace('\\', "/"); + let title = if cfg!(unix) { + Path::new(&title).file_name().unwrap().to_str().unwrap() + } else { + &title + }; // OSC 0 ; title BEL - works in most terminals print!("\x1B]0;{}\x07", title); // Ensure it's displayed immediately diff --git a/crates/shell/src/main.rs b/crates/shell/src/main.rs index 336fa86..d2fad7a 100644 --- a/crates/shell/src/main.rs +++ b/crates/shell/src/main.rs @@ -157,7 +157,17 @@ async fn interactive(state: Option, norc: bool, args: &[String]) -> } let mut display_cwd = if let Some(stripped) = cwd.strip_prefix(home_str) { - format!("~{}", stripped.replace('\\', "/")) + if cfg!(unix) { + format!( + "~/{}", + PathBuf::from(stripped.replace('\\', "/")) + .file_name() + .unwrap_or_default() + .to_string_lossy() + ) + } else { + format!("~{}", stripped.replace('\\', "/")) + } } else { cwd.to_string() };