summaryrefslogtreecommitdiffstats
path: root/src/format.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.rs')
-rw-r--r--src/format.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/format.rs b/src/format.rs
index 1560439..f2414cc 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -1,5 +1,15 @@
use std::os::unix::process::ExitStatusExt as _;
+pub fn path(path: &std::path::Path) -> String {
+ let mut path = path.display().to_string();
+ if let Ok(home) = std::env::var("HOME") {
+ if path.starts_with(&home) {
+ path.replace_range(..home.len(), "~");
+ }
+ }
+ path
+}
+
pub fn exit_status(status: std::process::ExitStatus) -> String {
status.signal().map_or_else(
|| format!("{:03} ", status.code().unwrap()),