Skip to content

Commit 6b6d26f

Browse files
authored
Merge pull request #2 from krisajenkins/fix/xdg-config-path
Use XDG_CONFIG_HOME for global config path
2 parents 32fd1fd + cc25745 commit 6b6d26f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/config.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ pub struct Config {
2424
pub index_warn_threshold: Option<usize>,
2525
}
2626

27-
/// Return the global config path (`~/.config/vecgrep/config.toml`).
27+
/// Return the global config path (`$XDG_CONFIG_HOME/vecgrep/config.toml`,
28+
/// defaulting to `~/.config/vecgrep/config.toml`).
2829
pub fn global_config_path() -> Option<PathBuf> {
29-
dirs::config_dir().map(|d| d.join("vecgrep").join("config.toml"))
30+
std::env::var_os("XDG_CONFIG_HOME")
31+
.map(PathBuf::from)
32+
.or_else(|| dirs::home_dir().map(|h| h.join(".config")))
33+
.map(|d| d.join("vecgrep").join("config.toml"))
3034
}
3135

3236
/// Return the project config path (`<project_root>/.vecgrep/config.toml`).

0 commit comments

Comments
 (0)