summaryrefslogtreecommitdiffstats
path: root/src/files.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/files.rs b/src/files.rs
index 5cc7dd8..49741df 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -602,4 +602,15 @@ impl File {
= chrono::Local.timestamp(self.meta().unwrap().mtime(), 0);
Some(time.format("%F %R").to_string())
}
+
+ pub fn short_path(&self) -> HResult<PathBuf> {
+ if let Ok(home) = crate::paths::home_path() {
+ if let Ok(short) = self.path.strip_prefix(home) {
+ let mut path = PathBuf::from("~");
+ path.push(short);
+ return Ok(path);
+ }
+ }
+ return Ok(self.path.clone())
+ }
}