From dcef667811baf8c1eced9c05af564319bc1e1c29 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 30 Nov 2025 11:53:41 -0800 Subject: [PATCH] fix(config): ensure pathext replaces ~ with $home --- komorebi/src/core/pathext.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/komorebi/src/core/pathext.rs b/komorebi/src/core/pathext.rs index 3713ac40..34be424e 100644 --- a/komorebi/src/core/pathext.rs +++ b/komorebi/src/core/pathext.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::env; use std::ffi::OsStr; use std::path::Component; use std::path::Path; @@ -34,6 +33,12 @@ impl> PathExt for P { c = OsStr::new("$Env:USERPROFILE"); } + #[cfg(target_os = "macos")] + // Special case for ~, replace with $HOME + if c == OsStr::new("~") { + c = OsStr::new("$HOME"); + } + let bytes = c.as_encoded_bytes(); // %LOCALAPPDATA% @@ -60,7 +65,7 @@ impl> PathExt for P { // if component is a variable, get the value from the environment if let Some(var) = var { let var = unsafe { OsStr::from_encoded_bytes_unchecked(var) }; - if let Some(value) = env::var_os(var) { + if let Some(value) = std::env::var_os(var) { out.push(value); continue; } @@ -206,6 +211,7 @@ mod tests { } // ~ and $HOME should be replaced with $Env:USERPROFILE + assert_eq!(resolve("~"), expected("/Users/user")); assert_eq!(resolve("$HOME"), expected("/Users/user")); } }