mirror of
https://github.com/wez/wezterm.git
synced 2024-11-28 01:06:37 +03:00
load config from executable dir first on Windows
This is to support the portable-tools use case for roaming admins. Refs: https://github.com/wez/wezterm/issues/73
This commit is contained in:
parent
0558662813
commit
500b880b97
@ -402,15 +402,31 @@ impl Config {
|
|||||||
// specific config directories, but only returns one of them, not
|
// specific config directories, but only returns one of them, not
|
||||||
// multiple. In addition, it spawns a lot of subprocesses,
|
// multiple. In addition, it spawns a lot of subprocesses,
|
||||||
// so we do this bit "by-hand"
|
// so we do this bit "by-hand"
|
||||||
let paths = [
|
let mut paths = vec![
|
||||||
HOME_DIR
|
HOME_DIR
|
||||||
.join(".config")
|
.join(".config")
|
||||||
.join("wezterm")
|
.join("wezterm")
|
||||||
.join("wezterm.toml"),
|
.join("wezterm.toml"),
|
||||||
HOME_DIR.join(".wezterm.toml"),
|
HOME_DIR.join(".wezterm.toml"),
|
||||||
];
|
];
|
||||||
|
if cfg!(windows) {
|
||||||
|
// On Windows, a common use case is to maintain a thumb drive
|
||||||
|
// with a set of portable tools that don't need to be installed
|
||||||
|
// to run on a target system. In that scenario, the user would
|
||||||
|
// like to run with the config from their thumbdrive because
|
||||||
|
// either the target system won't have any config, or will have
|
||||||
|
// the config of another user.
|
||||||
|
// So we prioritize that here: if there is a config in the same
|
||||||
|
// dir as the executable that will take precedence.
|
||||||
|
if let Ok(exe_name) = std::env::current_exe() {
|
||||||
|
if let Some(exe_dir) = exe_name.parent() {
|
||||||
|
paths.insert(0, exe_dir.join("wezterm.toml"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for p in &paths {
|
for p in &paths {
|
||||||
|
log::trace!("consider config: {}", p.display());
|
||||||
let mut file = match fs::File::open(p) {
|
let mut file = match fs::File::open(p) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(err) => match err.kind() {
|
Err(err) => match err.kind() {
|
||||||
|
Loading…
Reference in New Issue
Block a user