aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Corona <ac@albertocorona.com>2017-01-09 00:40:47 -0600
committerJoe Wilm <jwilm@users.noreply.github.com>2017-01-09 09:23:32 -0800
commitc314fb25cd60eaecbab18474207dbc9e65dc8233 (patch)
tree81f03ee799f0321bcd4bb2e8ee98a5844e17c3c3
parent929403386cd855a1715334db9c6c4cd1ae08f4a6 (diff)
downloadalacritty-c314fb25cd60eaecbab18474207dbc9e65dc8233.tar.gz
alacritty-c314fb25cd60eaecbab18474207dbc9e65dc8233.zip
Add another optional config path `$HOME/.alacritty.yml`
- Added note about the default file created if no path is found
-rw-r--r--README.md6
-rw-r--r--src/config.rs15
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<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)