create mountpoint_cd command

This commit is contained in:
Lutsay Aleksandr Valeryevich 2024-12-01 02:07:19 +03:00
parent 854f92446a
commit 6cc018cb22
2 changed files with 10 additions and 2 deletions

View file

@ -195,6 +195,9 @@ keymap = [
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" }, { on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" }, { on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Enter>", run = "mountpoint_cd", desc = "Change directory to selected mountpoint" },
{ on = "l", run = "mountpoint_cd", desc = "Change directory to selected mountpoint" },
# Help # Help
{ on = "~", run = "help", desc = "Open help" }, { on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" }, { on = "<F1>", run = "help", desc = "Open help" },

View file

@ -1,9 +1,14 @@
use yazi_macro::emit;
use yazi_proxy::options::ProcessExecOpt; use yazi_proxy::options::ProcessExecOpt;
use yazi_shared::{Layer, event::Cmd, fs::Url};
use crate::mount::Mount; use crate::mount::Mount;
impl Mount { impl Mount {
pub fn mountpoint_cd(&mut self, opt: impl TryInto<ProcessExecOpt>) { pub fn mountpoint_cd(&mut self, _opt: impl TryInto<ProcessExecOpt>) {
if let Ok(opt) = opt.try_into() {} if let Some(target) = self.points.get(self.cursor) {
let url: Url = target.path.clone().into();
emit!(Call(Cmd::args("cd", &[url]), Layer::Manager));
}
} }
} }