mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 22:31:35 +03:00
feat: add interactive cd (#43)
This commit is contained in:
parent
866ed17044
commit
4823c0abc4
@ -67,8 +67,12 @@ impl Executor {
|
||||
"forward" => cx.manager.active_mut().forward(),
|
||||
"cd" => {
|
||||
let path = exec.args.get(0).map(PathBuf::from).unwrap_or_default();
|
||||
emit!(Cd(path));
|
||||
false
|
||||
if exec.named.contains_key("interactive") {
|
||||
cx.manager.active_mut().cd_interactive(path)
|
||||
} else {
|
||||
emit!(Cd(path));
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// Selection
|
||||
|
@ -97,6 +97,7 @@ keymap = [
|
||||
{ on = [ "g", "c" ], exec = "cd ~/.config" },
|
||||
{ on = [ "g", "d" ], exec = "cd ~/Downloads" },
|
||||
{ on = [ "g", "t" ], exec = "cd /tmp" },
|
||||
{ on = [ "g", "<Space>" ], exec = "cd --interactive" },
|
||||
]
|
||||
|
||||
[tasks]
|
||||
|
@ -115,6 +115,18 @@ impl Tab {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn cd_interactive(&mut self, target: PathBuf) -> bool {
|
||||
tokio::spawn(async move {
|
||||
let result =
|
||||
emit!(Input(InputOpt::top("Change directory:").with_value(target.to_string_lossy())));
|
||||
|
||||
if let Ok(target) = result.await {
|
||||
emit!(Cd(PathBuf::from(target)));
|
||||
}
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
pub fn enter(&mut self) -> bool {
|
||||
let hovered = if let Some(ref h) = self.current.hovered {
|
||||
h.clone()
|
||||
|
Loading…
Reference in New Issue
Block a user