From a3ea0c304a789419ac9578c4e8d155f22bcb0af5 Mon Sep 17 00:00:00 2001 From: goldfish <37319612+ito-hiroki@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:37:54 +0900 Subject: [PATCH] Fix `config {nu,env}` to open `$nu.{config,env}-file` (#8792) # Description fixed #8755 Now, command `config {nu,env}` opens default file `.config/nushell/{config,env}.nu`. This behavior is inappropriate when `nu` is launched with option `--config` or `--env-config`. This PR changes the file that the command opens to `$nu.{config,env}-file`. # User-Facing Changes `config {nu,env}` opens `$nu.{config,env}-file`. --- crates/nu-command/src/env/config/config_env.rs | 11 ++++------- crates/nu-command/src/env/config/config_nu.rs | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/nu-command/src/env/config/config_env.rs b/crates/nu-command/src/env/config/config_env.rs index dd0fad7a90..e1693b392f 100644 --- a/crates/nu-command/src/env/config/config_env.rs +++ b/crates/nu-command/src/env/config/config_env.rs @@ -42,21 +42,18 @@ impl Command for ConfigEnv { input: PipelineData, ) -> Result { let env_vars_str = env_to_strings(engine_state, stack)?; - let mut config_path = match nu_path::config_dir() { - Some(path) => path, + let nu_config = match engine_state.get_config_path("env-path") { + Some(path) => path.clone(), None => { return Err(ShellError::GenericError( - "Could not find nu env path".to_string(), - "Could not find nu env path".to_string(), + "Could not find $nu.env-path".to_string(), + "Could not find $nu.env-path".to_string(), None, None, Vec::new(), )); } }; - config_path.push("nushell"); - let mut nu_config = config_path.clone(); - nu_config.push("env.nu"); let (item, config_args) = get_editor(engine_state, stack, call.head)?; diff --git a/crates/nu-command/src/env/config/config_nu.rs b/crates/nu-command/src/env/config/config_nu.rs index f03f798e8d..1591942f9a 100644 --- a/crates/nu-command/src/env/config/config_nu.rs +++ b/crates/nu-command/src/env/config/config_nu.rs @@ -42,21 +42,18 @@ impl Command for ConfigNu { input: PipelineData, ) -> Result { let env_vars_str = env_to_strings(engine_state, stack)?; - let mut config_path = match nu_path::config_dir() { - Some(path) => path, + let nu_config = match engine_state.get_config_path("config-path") { + Some(path) => path.clone(), None => { return Err(ShellError::GenericError( - "Could not find nu config path".to_string(), - "Could not find nu config path".to_string(), + "Could not find $nu.config-path".to_string(), + "Could not find $nu.config-path".to_string(), None, None, Vec::new(), )); } }; - config_path.push("nushell"); - let mut nu_config = config_path.clone(); - nu_config.push("config.nu"); let (item, config_args) = get_editor(engine_state, stack, call.head)?;