diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs
index fc6ddb1242..2d147ea081 100644
--- a/crates/nu-command/src/filesystem/cd.rs
+++ b/crates/nu-command/src/filesystem/cd.rs
@@ -188,6 +188,11 @@ impl Command for Cd {
example: r#"cd d/s/9"#,
result: None,
},
+ Example {
+ description: "Change to the previous working directory ($OLDPWD)",
+ example: r#"cd -"#,
+ result: None,
+ },
]
}
}
diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs
index 9319b94426..aa93e2ce4b 100644
--- a/crates/nu-command/tests/format_conversions/html.rs
+++ b/crates/nu-command/tests/format_conversions/html.rs
@@ -56,7 +56,7 @@ fn test_cd_html_color_flag_dark_false() {
);
assert_eq!(
actual.out,
- r"
Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display this help message
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
"
+ r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display this help message
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
);
}
@@ -71,6 +71,6 @@ fn test_no_color_flag() {
);
assert_eq!(
actual.out,
- r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display this help message
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
"
+ r"Change directory.
Usage:
> cd (path)
Flags:
-h, --help
Display this help message
Parameters:
(optional) path <Directory>: the path to change to
Examples:
Change to your home directory
> cd ~
Change to a directory via abbreviations
> cd d/s/9
Change to the previous working directory ($OLDPWD)
> cd -
"
);
}