Skip to main content

format_path_for_display

Function format_path_for_display 

Source
pub fn format_path_for_display(path: &Path) -> String
Expand description

Format a filesystem path for user-facing output.

Replaces home directory prefix with ~ when safe for shell use. Falls back to quoted absolute path when escaping is needed (to avoid tilde-in-quotes issues).

Uses POSIX shell escaping since all our hints target POSIX-compatible shells (bash, zsh, fish, and Git Bash on Windows).

§Examples

  • /Users/alex/repo~/repo (no escaping needed)
  • /Users/alex/my repo'/Users/alex/my repo' (needs quoting, use original)
  • /tmp/repo/tmp/repo (no escaping needed)
  • /tmp/my repo'/tmp/my repo' (needs quoting)