From e9c5e1d85c5c1d3310fb7994c474f9462c0bca97 Mon Sep 17 00:00:00 2001 From: YummyOreo Date: Sun, 5 Mar 2023 13:00:59 -0600 Subject: Windows support (#754) * adds support for getting home dir in windows * fixes bug * adds windows server support + build for linux ^| todo: test server on linux * improvements to redability * removes comment * returns if windows when importing auto * this should be here, to prevent double inputs * adds explanation to why we have to throw away 1 event in the tui * better message when running atuin import on windows + spell fix --- atuin-common/src/utils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'atuin-common/src') 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); -- cgit v1.3.1