summaryrefslogtreecommitdiffstats
path: root/src/modules/directory.rs
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-08 17:35:38 -0400
committerMatan Kushner <hello@matchai.me>2019-04-08 17:35:38 -0400
commitd58ea0659b3f0c4a62c1165a597d72757b99d088 (patch)
treec9de0ebe51d3d1cc23a74898c9b632fd7c66d873 /src/modules/directory.rs
parent0e0bed08374404ff6db953e0d1b994c139545d29 (diff)
Add a new line before the prompt
Diffstat (limited to 'src/modules/directory.rs')
-rw-r--r--src/modules/directory.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/modules/directory.rs b/src/modules/directory.rs
index a028506fb..9b5b81959 100644
--- a/src/modules/directory.rs
+++ b/src/modules/directory.rs
@@ -66,6 +66,11 @@ fn get_repo_root(repo: Repository) -> PathBuf {
}
/// Truncate a path to a predefined number of path components
+///
+/// Trim the path in the prompt to only have the last few paths, set by `length`.
+/// This function also serves to replace the top-level path of the prompt.
+/// This can be used to replace the path to a git repo with only the repo
+/// directory name.
fn truncate_path(
length: &usize,
full_path: &PathBuf,
@@ -91,10 +96,10 @@ fn truncate_path(
}
format!(
- "{}{}{}",
- top_level_replacement,
- std::path::MAIN_SEPARATOR,
- full_path
+ "{replacement}{separator}{path}",
+ replacement = top_level_replacement,
+ separator = std::path::MAIN_SEPARATOR,
+ path = full_path
.iter()
.skip(top_level_path_depth)
.collect::<PathBuf>()