From c314fb25cd60eaecbab18474207dbc9e65dc8233 Mon Sep 17 00:00:00 2001 From: Alberto Corona Date: Mon, 9 Jan 2017 00:40:47 -0600 Subject: Add another optional config path `$HOME/.alacritty.yml` - Added note about the default file created if no path is found --- src/config.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') 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) -- cgit