Function shellexpand::tilde

source ·
pub fn tilde<SI>(input: &SI) -> Cow<'_, str>
where SI: AsRef<str> + ?Sized,
Expand description

Performs the tilde expansion using the default system context.

This function delegates to tilde_with_context(), using the default system source of home directory path, namely dirs::home_dir() function.

§Examples

let hds = dirs::home_dir()
    .map(|p| p.display().to_string())
    .unwrap_or_else(|| "~".to_owned());

assert_eq!(
    shellexpand::tilde("~/some/dir"),
    format!("{}/some/dir", hds)
);