add home-path to $nu (#468)

This commit is contained in:
Darren Schroeder 2021-12-11 13:12:30 -06:00 committed by GitHub
parent d0119ea05d
commit 4103abc685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -520,6 +520,16 @@ pub fn eval_variable(
}
}
if let Some(home_path) = nu_path::home_dir() {
if let Some(home_path_str) = home_path.to_str() {
output_cols.push("home-path".into());
output_vals.push(Value::String {
val: home_path_str.into(),
span,
})
}
}
if let Ok(cwd) = std::env::var("PWD") {
output_cols.push("pwd".into());
output_vals.push(Value::String { val: cwd, span })