Resolve the XDG config base directory. Returns `$XDG_CONFIG_HOME` if set, otherwise `$HOME/.config`.
()
| 17 | /// |
| 18 | /// Returns `$XDG_CONFIG_HOME` if set, otherwise `$HOME/.config`. |
| 19 | pub fn xdg_config_dir() -> Result<PathBuf> { |
| 20 | if let Ok(path) = std::env::var("XDG_CONFIG_HOME") { |
| 21 | return Ok(PathBuf::from(path)); |
| 22 | } |
| 23 | let home = std::env::var("HOME") |
| 24 | .into_diagnostic() |
| 25 | .wrap_err("HOME is not set")?; |
| 26 | Ok(PathBuf::from(home).join(".config")) |
| 27 | } |
| 28 | |
| 29 | /// The top-level `OpenShell` config directory: `$XDG_CONFIG_HOME/openshell/`. |
| 30 | pub fn openshell_config_dir() -> Result<PathBuf> { |
no outgoing calls