notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

path_utils.rs (341B)


      1 use std::path::Path;
      2 
      3 /// Abbreviate a path for display (e.g., replace home dir with ~)
      4 pub fn abbreviate_path(path: &Path) -> String {
      5     if let Some(home) = dirs::home_dir() {
      6         if let Ok(relative) = path.strip_prefix(&home) {
      7             return format!("~/{}", relative.display());
      8         }
      9     }
     10     path.display().to_string()
     11 }