From 188727a09f0369651a007f37fdb63ef8bc4bbdad Mon Sep 17 00:00:00 2001 From: Yiang Date: Wed, 27 Nov 2024 13:23:38 +0800 Subject: [PATCH] feat: support cd - (cd last) --- yazi-core/src/tab/commands/cd.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index 69b59e29..672cf46c 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -26,7 +26,7 @@ impl From for Opt { impl From for Opt { fn from(mut target: Url) -> Self { - if target.is_regular() { + if target.is_regular() && target.to_string() != "-" { target = Url::from(expand_path(&target)); } Self { target, interactive: false } @@ -48,6 +48,15 @@ impl Tab { return; } + if opt.target.to_string() == "-" { + if let Some(last_cwd) = self.backstack.shift_backward() { + TabProxy::cd(&last_cwd); + } + + self.backstack.push(self.cwd().clone()); + return; + } + // Take parent to history if let Some(rep) = self.parent.take() { self.history.insert(rep.url.to_owned(), rep);