diff --git a/src/args.rs b/src/args.rs index 9689164a51..b4ad901072 100644 --- a/src/args.rs +++ b/src/args.rs @@ -141,8 +141,15 @@ fn setup_logging() -> Result<()> { } fn get_app_cache_path() -> Result { - let mut path = dirs_next::cache_dir() - .ok_or_else(|| anyhow!("failed to find os cache dir."))?; + let mut path = if cfg!(windows) { + env::var("XDG_CACHE_HOME") + .ok() + .map(PathBuf::from) + .or_else(dirs_next::cache_dir) + } else { + dirs_next::cache_dir() + } + .ok_or_else(|| anyhow!("failed to find os cache dir."))?; path.push("gitui"); fs::create_dir_all(&path)?; @@ -152,6 +159,11 @@ fn get_app_cache_path() -> Result { pub fn get_app_config_path() -> Result { let mut path = if cfg!(target_os = "macos") { dirs_next::home_dir().map(|h| h.join(".config")) + } else if cfg!(windows) { + env::var("XDG_CONFIG_HOME") + .ok() + .map(PathBuf::from) + .or_else(dirs_next::config_dir) } else { dirs_next::config_dir() }