mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 08:29:07 +01:00
Replace only leading home path with ~
in the title (#13600)
# Description : - This pull request addresses issue #13594 where any substring of the path that matches the home directory is replaced with `~` in the title bar. This was problematic because partial matches within the path were also being replaced. --------- Signed-off-by: Aakash788 <aakashparmar788@gmail.com> Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
80c8edcfb4
commit
0eabbb88dd
@ -911,7 +911,12 @@ fn run_shell_integration_osc2(
|
||||
|
||||
// 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(), "~")
|
||||
let home_dir_str = p.as_path().display().to_string();
|
||||
if path.starts_with(&home_dir_str) {
|
||||
path.replacen(&home_dir_str, "~", 1)
|
||||
} else {
|
||||
path
|
||||
}
|
||||
} else {
|
||||
path
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user