diff --git a/Cargo.toml b/Cargo.toml index 64632430d..74cefab3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ serde = "1.0.27" serde_derive = "1.0.27" toml = "0.4.5" unicode-width = "0.1.4" +directories = "~1.0" [dependencies.term] path = "term" diff --git a/src/config.rs b/src/config.rs index fdcb57a9d..a716b161d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,6 @@ //! Configuration for the gui portion of the terminal +use directories::UserDirs; use failure::{err_msg, Error}; use std; use std::fs; @@ -175,8 +176,13 @@ pub struct StyleRule { impl Config { pub fn load() -> Result { - let home = std::env::home_dir().ok_or_else(|| err_msg("can't find home dir"))?; + let dirs = UserDirs::new() + .ok_or_else(|| err_msg("can't find home dir"))?; + let home = dirs.home_dir(); + // Note that the directories crate has methods for locating project + // specific config directories, but only returns one of them, not + // multiple. Not sure how feel about that. let paths = [ home.join(".config").join("wezterm").join("wezterm.toml"), home.join(".wezterm.toml"), diff --git a/src/main.rs b/src/main.rs index 20a1e002d..adcd8ea6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ extern crate clap; #[cfg(target_os = "macos")] extern crate core_text; +extern crate directories; extern crate euclid; #[macro_use] extern crate failure;