fn to_fish_style(pwd_dir_length: usize, dir_string: String, truncated_dir_string: &str) -> String {
    let replaced_dir_string = dir_string.trim_end_matches(truncated_dir_string).to_owned();
    let components = replaced_dir_string.split('/').collect::<Vec<&str>>();

    if components.is_empty() {
        return replaced_dir_string;
    }

    components
        .into_iter()
        .map(|word| -> String {
            let chars = UnicodeSegmentation::graphemes(word, true).collect::<Vec<&str>>();
            match word {
                "" => "".to_string(),
                _ if chars.len() <= pwd_dir_length => word.to_string(),
                _ if word.starts_with('.') => chars[..=pwd_dir_length].join(""),
                _ => chars[..pwd_dir_length].join(""),
            }
        })
        .collect::<Vec<_>>()
        .join("/")
}
/// Takes part before contracted path and replaces it with fish style path
///
/// Will take the first letter of each directory before the contracted path and
/// use that in the path instead. See the following example.
///
/// Absolute Path: `/Users/Bob/Projects/work/a_repo`
/// Contracted Path: `a_repo`
/// With Fish Style: `~/P/w/a_repo`
///
/// Absolute Path: `/some/Path/not/in_a/repo/but_nested`
/// Contracted Path: `in_a/repo/but_nested`
/// With Fish Style: `/s/P/n/in_a/repo/but_nested`
Takes part before contracted path and replaces it with fish style path
Will take the first letter of each directory before the contracted path and
use that in the path instead. See the following example.




Takes part before contracted path and replaces it with fish style path Will take the first letter of each directory before the contracted path and use that in the path instead . See the following example .
fn to_fish_style(pwd_dir_length: usize, dir_string: String, truncated_dir_string: &str) -> String {
    let replaced_dir_string = dir_string.trim_end_matches(truncated_dir_string).to_owned();
    let components = replaced_dir_string.split('/').collect::<Vec<&str>>();
    if components.is_empty() {
        return replaced_dir_string;
    }
    components
        .into_iter()
        .map(|word| -> String {
            let chars = UnicodeSegmentation::graphemes(word, true).collect::<Vec<&str>>();
            match word {
                "" => "".to_string(),
                _ if chars.len() <= pwd_dir_length => word.to_string(),
                _ if word.starts_with('.') => chars[..=pwd_dir_length].join(""),
                _ => chars[..pwd_dir_length].join(""),
            }
        })
        .collect::<Vec<_>>()
        .join("/")
}
fn to_fish_style ( pwd_dir_length : usize , dir_string : String , truncated_dir_string : & str ) -> String { let replaced_dir_string = dir_string . trim_end_matches ( truncated_dir_string ) . to_owned ( ) ; let components = replaced_dir_string . split ( '/' ) . collect :: < Vec < & str > > ( ) ; if components . is_empty ( ) { return replaced_dir_string ; } components . into_iter ( ) . map ( | word | -> String { let chars = UnicodeSegmentation :: graphemes ( word , true ) . collect :: < Vec < & str > > ( ) ; match word { " " => " " . to_string ( ) , _ if chars . len ( ) <= pwd_dir_length => word . to_string ( ) , _ if word . starts_with ( '.' ) => chars [ .. = pwd_dir_length ] . join ( " " ) , _ => chars [ .. pwd_dir_length ] . join ( " " ) , } } ) . collect :: < Vec < _ > > ( ) . join ( " " ) }
Takes part before contracted path and replaces it with fish style path
Will take the first letter of each directory before the contracted path and
use that in the path instead.
Takes part before contracted path and replaces it with fish style path Will take the first letter of each directory before the contracted path and use that in the path instead .
pwd_dir_length
usize
dir_string
String
truncated_dir_string
&str