1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-03 04:34:21 -05:00

Add another optional config path $HOME/.alacritty.yml

- Added note about the default file created if no path is found
This commit is contained in:
Alberto Corona 2017-01-09 00:40:47 -06:00 committed by Joe Wilm
parent 929403386c
commit c314fb25cd
2 changed files with 15 additions and 6 deletions

View file

@ -145,9 +145,11 @@ file as the following paths:
1. `$XDG_CONFIG_HOME/alacritty/alacritty.yml`
2. `$XDG_CONFIG_HOME/alacritty.yml`
3. `$HOME/.config/alacritty/alacritty.yml`
4. `$HOME/.alacritty.yml`
If neither path 1 or 2 are found then `$HOME/.config/alacritty/alacritty.yml`
is created as or once alacritty is first run.
If neither of these paths are found then `$XDG_CONFIG_HOME/alacritty/alacritty.yml`
is created once alacritty is first run. On most systems this often defaults
to `$HOME/.config/alacritty/alacritty.yml`.
Many configuration options will take effect immediately upon saving changes to
the config file. The only exception is the `font` and `dpi` section which

View file

@ -814,6 +814,7 @@ impl Config {
/// 1. $XDG_CONFIG_HOME/alacritty/alacritty.yml
/// 2. $XDG_CONFIG_HOME/alacritty.yml
/// 3. $HOME/.config/alacritty/alacritty.yml
/// 4. $HOME/.alacritty.yml
pub fn load() -> Result<Config> {
let home = env::var("HOME")?;
@ -826,11 +827,17 @@ impl Config {
fallback.find_config_file("alacritty.yml")
})
})
.unwrap_or_else(|| {
.or_else(|| {
// Fallback path: $HOME/.config/alacritty/alacritty.yml
let mut alt_path = PathBuf::from(&home);
alt_path.push(".config/alacritty/alacritty.yml");
alt_path
let fallback = PathBuf::from(&home).join(".config/alacritty/alacritty.yml");
match fallback.exists() {
true => Some(fallback),
false => None
}
})
.unwrap_or_else(|| {
// Fallback path: $HOME/.alacritty.yml
PathBuf::from(&home).join(".alacritty.yml")
});
Config::load_from(path)