aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'atuin-common/src')
-rw-r--r--atuin-common/src/utils.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/atuin-common/src/utils.rs b/atuin-common/src/utils.rs
index a73e3fba..d85b3b96 100644
--- a/atuin-common/src/utils.rs
+++ b/atuin-common/src/utils.rs
@@ -10,11 +10,19 @@ pub fn uuid_v4() -> String {
// TODO: more reliable, more tested
// I don't want to use ProjectDirs, it puts config in awkward places on
// mac. Data too. Seems to be more intended for GUI apps.
+
+#[cfg(not(target_os = "windows"))]
pub fn home_dir() -> PathBuf {
let home = std::env::var("HOME").expect("$HOME not found");
PathBuf::from(home)
}
+#[cfg(target_os = "windows")]
+pub fn home_dir() -> PathBuf {
+ let home = std::env::var("USERPROFILE").expect("%userprofile% not found");
+ PathBuf::from(home)
+}
+
pub fn config_dir() -> PathBuf {
let config_dir =
std::env::var("XDG_CONFIG_HOME").map_or_else(|_| home_dir().join(".config"), PathBuf::from);