From 7ec20cfac0e28052d944c5e745b093fea2703aeb Mon Sep 17 00:00:00 2001 From: NotTheDr01ds <32344964+NotTheDr01ds@users.noreply.github.com> Date: Thu, 1 Aug 2024 14:28:49 -0400 Subject: [PATCH] Doc and examples for multi-dot directory traversal --- crates/nu-command/src/filesystem/cd.rs | 12 +++++++++++- crates/nu-command/src/filesystem/ucp.rs | 5 +++++ crates/nu-command/src/filesystem/umv.rs | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index ba91e6d0ca..87071d2888 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -134,7 +134,7 @@ impl Command for Cd { result: None, }, Example { - description: "Change to the previous working directory ($OLDPWD)", + description: r#"Change to the previous working directory (same as "cd $env.OLDPWD")"#, example: r#"cd -"#, result: None, }, @@ -143,6 +143,16 @@ impl Command for Cd { example: r#"def --env gohome [] { cd ~ }"#, result: None, }, + Example { + description: "Move two directories up in the tree (the parent directory's parent). Additional dots can be added for additional levels.", + example: r#"cd ..."#, + result: None, + }, + Example { + description: "The cd command itself is often optional. Simply entering a path to a directory will cd to it.", + example: r#"/home"#, + result: None, + }, ] } } diff --git a/crates/nu-command/src/filesystem/ucp.rs b/crates/nu-command/src/filesystem/ucp.rs index 447751220d..d99119c5e5 100644 --- a/crates/nu-command/src/filesystem/ucp.rs +++ b/crates/nu-command/src/filesystem/ucp.rs @@ -99,6 +99,11 @@ impl Command for UCp { example: "cp --preserve [] a b", result: None, }, + Example { + description: "Copy file to a directory three levels above its current location", + example: "cp myfile ....", + result: None, + }, ] } diff --git a/crates/nu-command/src/filesystem/umv.rs b/crates/nu-command/src/filesystem/umv.rs index 12d95e015b..9f68a6697f 100644 --- a/crates/nu-command/src/filesystem/umv.rs +++ b/crates/nu-command/src/filesystem/umv.rs @@ -40,6 +40,11 @@ impl Command for UMv { example: "mv *.txt my/subdirectory", result: None, }, + Example { + description: r#"Move a file into the "my" directory two levels up in the directory tree"#, + example: "mv test.txt .../my/", + result: None, + }, ] }