add smart-paste plugin from the docs (#107)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
Lucas Amion
2025-04-27 07:16:15 -04:00
committed by GitHub
parent 4b027c7937
commit 864a0210d9
4 changed files with 41 additions and 0 deletions

1
smart-paste.yazi/LICENSE Normal file
View File

@@ -0,0 +1 @@
../LICENSE

View File

@@ -0,0 +1,26 @@
# smart-paste.yazi
Paste files into the hovered directory or to the CWD if hovering over a file.
https://github.com/user-attachments/assets/b3f6348e-abbe-42fe-9a67-a96e68f11255
## Installation
```sh
ya pack -a yazi-rs/plugins:smart-paste
```
## Usage
Add this to your `~/.config/yazi/keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = "p"
run = "plugin smart-paste"
desc = "Paste into the hovered directory or CWD"
```
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.

13
smart-paste.yazi/main.lua Normal file
View File

@@ -0,0 +1,13 @@
--- @sync entry
return {
entry = function()
local h = cx.active.current.hovered
if h and h.cha.is_dir then
ya.mgr_emit("enter", {})
ya.mgr_emit("paste", {})
ya.mgr_emit("leave", {})
else
ya.mgr_emit("paste", {})
end
end,
}