From c314fb25cd60eaecbab18474207dbc9e65dc8233 Mon Sep 17 00:00:00 2001 From: Alberto Corona Date: Mon, 9 Jan 2017 00:40:47 -0600 Subject: [PATCH] Add another optional config path `$HOME/.alacritty.yml` - Added note about the default file created if no path is found --- README.md | 6 ++++-- src/config.rs | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7336533f..ae426dcc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/config.rs b/src/config.rs index b3ca5bdb..e9cd505a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 { 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)