feat: support cd - (cd last)

This commit is contained in:
Yiang 2024-11-27 13:23:38 +08:00
parent 5e48df5126
commit 188727a09f

View file

@ -26,7 +26,7 @@ impl From<Cmd> for Opt {
impl From<Url> 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);