mirror of
https://github.com/alacritty/alacritty.git
synced 2026-11-27 16:08:43 +03:00
Add support for '~/' in config imports
This allows the configuration file imports to start with '~/' and resolve relative to the user's home directory. There is no support for '~user/' or '$HOME/' or any other shell expansion. However since paths relative to the home directory should be sufficient for everything, this provides a very simple solution without any significant drawbacks. Fixes #4157.
This commit is contained in:
1 parent
da6f0a505e
commit
07cfe8bbba
5 files changed
+28
-9
No files matched your search
@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## 0.7.0-dev
|
## 0.7.0-dev
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for `~/` at the beginning of configuration file imports
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Nonexistent config imports are ignored instead of raising an error
|
- Nonexistent config imports are ignored instead of raising an error
|
||||||
|
|||||||
Generated
+11
-2
@@ -30,7 +30,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"copypasta",
|
"copypasta",
|
||||||
"crossfont",
|
"crossfont",
|
||||||
"dirs",
|
"dirs 3.0.1",
|
||||||
"embed-resource",
|
"embed-resource",
|
||||||
"fnv",
|
"fnv",
|
||||||
"gl_generator",
|
"gl_generator",
|
||||||
@@ -595,6 +595,15 @@ dependencies = [
|
|||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs"
|
||||||
|
version = "3.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff"
|
||||||
|
dependencies = [
|
||||||
|
"dirs-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
@@ -2043,7 +2052,7 @@ version = "0.7.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e"
|
checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs 2.0.2",
|
||||||
"fnv",
|
"fnv",
|
||||||
"nom",
|
"nom",
|
||||||
"phf",
|
"phf",
|
||||||
|
|||||||
+6
-3
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
# Import additional configuration files
|
# Import additional configuration files
|
||||||
#
|
#
|
||||||
# These configuration files will be loaded in order, replacing values in files
|
# Imports are loaded in order, skipping all missing files, with the importing
|
||||||
# loaded earlier with those loaded later in the chain. The file itself will
|
# file being loaded last. If a field is already present in a previous import, it
|
||||||
# always be loaded last. If an import path cannot be found it will be skipped.
|
# will be replaced.
|
||||||
|
#
|
||||||
|
# All imports must either be absolute paths starting with `/`, or paths relative
|
||||||
|
# to the user's home directory starting with `~/`.
|
||||||
#import:
|
#import:
|
||||||
# - /path/to/alacritty.yml
|
# - /path/to/alacritty.yml
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ copypasta = { version = "0.7.0", default-features = false }
|
|||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.1"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
|
dirs = "2.0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gl_generator = "0.14.0"
|
gl_generator = "0.14.0"
|
||||||
@@ -43,9 +44,6 @@ image = { version = "0.23.3", default-features = false, features = ["ico"], opti
|
|||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
objc = "0.2.2"
|
objc = "0.2.2"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "macos", windows))'.dependencies]
|
|
||||||
dirs = "2.0.2"
|
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os="windows", target_os="macos")))'.dependencies]
|
[target.'cfg(not(any(target_os="windows", target_os="macos")))'.dependencies]
|
||||||
x11-dl = { version = "2", optional = true }
|
x11-dl = { version = "2", optional = true }
|
||||||
wayland-client = { version = "0.28.0", features = ["dlopen"], optional = true }
|
wayland-client = { version = "0.28.0", features = ["dlopen"], optional = true }
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ fn load_imports(config: &Value, config_paths: &mut Vec<PathBuf>, recursion_limit
|
|||||||
let mut merged = Value::Null;
|
let mut merged = Value::Null;
|
||||||
|
|
||||||
for import in imports {
|
for import in imports {
|
||||||
let path = match import {
|
let mut path = match import {
|
||||||
Value::String(path) => PathBuf::from(path),
|
Value::String(path) => PathBuf::from(path),
|
||||||
_ => {
|
_ => {
|
||||||
error!(
|
error!(
|
||||||
@@ -222,6 +222,11 @@ fn load_imports(config: &Value, config_paths: &mut Vec<PathBuf>, recursion_limit
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Resolve paths relative to user's home directory.
|
||||||
|
if let (Ok(stripped), Some(home_dir)) = (path.strip_prefix("~/"), dirs::home_dir()) {
|
||||||
|
path = home_dir.join(stripped);
|
||||||
|
}
|
||||||
|
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
info!(target: LOG_TARGET_CONFIG, "Skipping importing config; not found:");
|
info!(target: LOG_TARGET_CONFIG, "Skipping importing config; not found:");
|
||||||
info!(target: LOG_TARGET_CONFIG, " {:?}", path.display());
|
info!(target: LOG_TARGET_CONFIG, " {:?}", path.display());
|
||||||
|
|||||||
Reference in new issue
Block a user