enable cd to work with directory abbreviations (#5452)

* enable cd to work with abbreviations

* add abbreviation example

* fix tests

* make it configurable
This commit is contained in:
Darren Schroeder
2022-05-06 07:58:32 -05:00
committed by GitHub
parent 78a1879e36
commit 768ff47d28
9 changed files with 666 additions and 36 deletions

View File

@ -49,6 +49,7 @@ pub struct Config {
pub shell_integration: bool,
pub buffer_editor: String,
pub disable_table_indexes: bool,
pub cd_with_abbreviations: bool,
}
impl Default for Config {
@ -77,6 +78,7 @@ impl Default for Config {
shell_integration: false,
buffer_editor: String::new(),
disable_table_indexes: false,
cd_with_abbreviations: false,
}
}
}
@ -265,7 +267,6 @@ impl Value {
eprintln!("$config.buffer_editor is not a string")
}
}
"disable_table_indexes" => {
if let Ok(b) = value.as_bool() {
config.disable_table_indexes = b;
@ -273,6 +274,13 @@ impl Value {
eprintln!("$config.disable_table_indexes is not a bool")
}
}
"cd_with_abbreviations" => {
if let Ok(b) = value.as_bool() {
config.cd_with_abbreviations = b;
} else {
eprintln!("$config.disable_table_indexes is not a bool")
}
}
x => {
eprintln!("$config.{} is an unknown config setting", x)
}

View File

@ -636,6 +636,27 @@ Either make sure {0} is a string, or add a 'to_string' entry for it in ENV_CONVE
String,
#[label = "'{0}' is deprecated. Please use '{1}' instead."] Span,
),
/// Non-Unicode input received.
///
/// ## Resolution
///
/// Check that your path is UTF-8 compatible.
#[error("Non-Unicode input received.")]
#[diagnostic(code(nu::shell::non_unicode_input), url(docsrs))]
NonUnicodeInput,
// /// Path not found.
// #[error("Path not found.")]
// PathNotFound,
/// Unexpected abbr component.
///
/// ## Resolution
///
/// Check the path abbreviation to ensure that it is valid.
#[error("Unexpected abbr component `{0}`.")]
#[diagnostic(code(nu::shell::unexpected_path_abbreviateion), url(docsrs))]
UnexpectedAbbrComponent(String),
}
impl From<std::io::Error> for ShellError {