diff --git a/Cargo.lock b/Cargo.lock index b2cd6105..678f3502 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,6 +115,11 @@ dependencies = [ "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "shellexpand" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "0.11.11" @@ -179,6 +184,7 @@ dependencies = [ "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -239,6 +245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" "checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" "checksum serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "0a90213fa7e0f5eac3f7afe2d5ff6b088af515052cc7303bd68c7e3b91a3fb79" +"checksum shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de7a5b5a9142fd278a10e0209b021a1b85849352e6951f4f914735c976737564" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c67da57e61ebc7b7b6fff56bb34440ca3a83db037320b0507af4c10368deda7d" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" diff --git a/Cargo.toml b/Cargo.toml index 338eb3f0..3224137b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,4 @@ serde_derive = "1.0.66" termion = "1.5.1" toml = "0.4.6" which = "2.0.0" +shellexpand = "1.0.0" diff --git a/src/config.rs b/src/config.rs index 9a7f0a6a..11e12a31 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,6 @@ use directories; use failure; +use shellexpand; use std::collections::BTreeMap; use std::fs; use toml; @@ -18,7 +19,15 @@ impl Config { return Ok(Default::default()); } - Ok(toml::from_str(&fs::read_to_string(config_path)?)?) + let mut result: Self = toml::from_str(&fs::read_to_string(config_path)?)?; + + if let Some(ref mut paths) = &mut result.git_repos { + for path in paths.iter_mut() { + *path = shellexpand::tilde::<&str>(&path.as_ref()).into_owned(); + } + } + + Ok(result) } pub fn commands(&self) -> &Option> { diff --git a/src/main.rs b/src/main.rs index 7bda64bc..2baaee43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ extern crate toml; #[macro_use] extern crate serde_derive; extern crate serde; +extern crate shellexpand; mod config; mod git;