Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions crates/deno_task_shell/src/shell/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::collections::HashMap;
use std::fmt;
use std::fmt::Display;
use std::fs;
use std::io::IsTerminal as _;
use std::io::Read;
use std::io::Write;
use std::path::Path;
Expand Down Expand Up @@ -54,16 +53,6 @@ pub struct ShellState {
shell_options: HashMap<ShellOptions, bool>,
}

#[allow(clippy::print_stdout)]
pub fn set_terminal_title(title: &str) {
// Only set title if we're in an interactive terminal session
if std::io::stdout().is_terminal() {
// OSC 0 ; title BEL - works in most terminals
print!("\x1B]0;{}\x07", title);
// Ensure it's displayed immediately
let _ = std::io::stdout().flush();
}
}

impl ShellState {
pub fn new(
Expand Down Expand Up @@ -186,7 +175,6 @@ impl ShellState {
self.previous_cwd = Some(self.cwd.clone());
self.cwd = cwd.to_path_buf();

set_terminal_title(&format!("{} - shell", self.cwd.to_string_lossy(),));
// $PWD holds the current working directory, so we keep cwd and $PWD in sync
self.env_vars
.insert("PWD".to_string(), self.cwd.display().to_string());
Expand Down
12 changes: 11 additions & 1 deletion crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,17 @@ async fn interactive(state: Option<ShellState>, 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()
};
Expand Down