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`.
This commit is contained in:
goldfish 2023-04-08 01:37:54 +09:00 committed by GitHub
parent 4fda6d7eaa
commit a3ea0c304a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View file

@ -42,21 +42,18 @@ impl Command for ConfigEnv {
input: PipelineData,
) -> Result<PipelineData, ShellError> {
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)?;

View file

@ -42,21 +42,18 @@ impl Command for ConfigNu {
input: PipelineData,
) -> Result<PipelineData, ShellError> {
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)?;