Small helper for formatting the path as a relative path, if able.
(cwd: impl AsRef<Path>, path: impl AsRef<Path>)
| 430 | |
| 431 | /// Small helper for formatting the path as a relative path, if able. |
| 432 | fn format_path(cwd: impl AsRef<Path>, path: impl AsRef<Path>) -> String { |
| 433 | absolute_to_relative(cwd, path.as_ref()) |
| 434 | .map(|p| p.to_string_lossy().to_string()) |
| 435 | // If we have three consecutive ".." then it should probably just stay as an absolute path. |
| 436 | .map(|p| { |
| 437 | let three_up = format!("..{}..{}..", std::path::MAIN_SEPARATOR, std::path::MAIN_SEPARATOR); |
| 438 | if p.starts_with(&three_up) { |
| 439 | path.as_ref().to_string_lossy().to_string() |
| 440 | } else { |
| 441 | p |
| 442 | } |
| 443 | }) |
| 444 | .unwrap_or(path.as_ref().to_string_lossy().to_string()) |
| 445 | } |
| 446 | |
| 447 | fn supports_truecolor() -> bool { |
| 448 | // Simple override to disable truecolor since shell_color doesn't use Context. |
no test coverage detected