From 6cc018cb22a7c7db2b73425488b691de78de0c91 Mon Sep 17 00:00:00 2001 From: Lutsay Aleksandr Valeryevich Date: Sun, 1 Dec 2024 02:07:19 +0300 Subject: [PATCH] create mountpoint_cd command --- yazi-config/preset/keymap.toml | 3 +++ yazi-core/src/mount/commands/mountpoint_cd.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 72ef513a1..1e5744c08 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -195,6 +195,9 @@ keymap = [ { on = "", run = "arrow -1", desc = "Move cursor up" }, { on = "", run = "arrow 1", desc = "Move cursor down" }, + { on = "", run = "mountpoint_cd", desc = "Change directory to selected mountpoint" }, + { on = "l", run = "mountpoint_cd", desc = "Change directory to selected mountpoint" }, + # Help { on = "~", run = "help", desc = "Open help" }, { on = "", run = "help", desc = "Open help" }, diff --git a/yazi-core/src/mount/commands/mountpoint_cd.rs b/yazi-core/src/mount/commands/mountpoint_cd.rs index 448f8b400..8d8c08162 100644 --- a/yazi-core/src/mount/commands/mountpoint_cd.rs +++ b/yazi-core/src/mount/commands/mountpoint_cd.rs @@ -1,9 +1,14 @@ +use yazi_macro::emit; use yazi_proxy::options::ProcessExecOpt; +use yazi_shared::{Layer, event::Cmd, fs::Url}; use crate::mount::Mount; impl Mount { - pub fn mountpoint_cd(&mut self, opt: impl TryInto) { - if let Ok(opt) = opt.try_into() {} + pub fn mountpoint_cd(&mut self, _opt: impl TryInto) { + if let Some(target) = self.points.get(self.cursor) { + let url: Url = target.path.clone().into(); + emit!(Call(Cmd::args("cd", &[url]), Layer::Manager)); + } } }