Closed hankertrix closed 3 days ago
Try:
{ on = [ "h" ], run = [ "leave", "escape --select" ] },
{ on = [ "l" ], run = [ "enter", , "escape --select" ] },
Doc of escape
command: https://yazi-rs.github.io/docs/configuration/keymap#manager.escape
Thank you for the blazingly fast response!
However, this wouldn't really work for my use case as I would like to be able to use cross-directory selection, but not shoot myself in the foot when I forget to deselect after selecting in another directory when I use the rename
and remove
commands.
Ideally, I would like to create a plugin that will only run the remove
and rename
commands on the selected files only when the currently hovered file is selected, like the plugin in this issue for the open
command.
Unless I'm missing something, I'd be willing to implement this feature as it seems trivial.
Ideally, I would like to create a plugin that will only run the remove and rename commands on the selected files only when the currently hovered file is selected, like the plugin in https://github.com/sxyazi/yazi/issues/807#issuecomment-1994973336 for the open command
It's possible. Basically, you just need to bind your remove
and rename
keys to your custom plugin. You can implement both in the same plugin; just differentiate them with parameters:
{ on = [ "d" ], run = [ "plugin --sync your-plugin --args=remove" ] },
{ on = [ "r" ], run = [ "plugin --sync your-plugin --args=rename" ] },
Then, in your plugin, when the conditions are met, use ya.manager_emit()
to emit them (remove
or rename
command).
Doc of ya.manager_emit()
: https://yazi-rs.github.io/docs/plugins/utils/#ya.manager_emit
I see, that's helpful.
The issue is that the remove
and rename
commands don't have the option to operate only on the hovered file like the open
command does. Emitting the rename
or remove
commands will end up operating on all of the selected files instead of just the hovered file.
I had this issue as well.
I like how it is solved in nnn. If you have some selection and try to do rename/open/delete on a file outside of the selection the file manager specifically asks what should be the object of the operation, the hover or the selection.
the file manager specifically asks what should be the object of the operation, the hover or the selection.
Do you have a screenshot or maybe a video of the prompt?
@mskvsk I implemented the prompt in my plugin, but you have to be on the latest Git version of Yazi for the prompt to work on the remove
and rename
commands.
Check it out here: https://github.com/hankertrix/augment-command.yazi
Please describe the problem you're trying to solve
With cross-directory selection, I often forget that I still have items selected before running the
rename
andremove
commands, which can end in disaster, especially for theremove
command.Would you be willing to contribute this feature?
Describe the solution you'd like
The
--hovered
option to be added for both therename
andremove
commands, similar to theopen
command.Additional context
Forgetting to unselect files:
Expecting to delete the currently hovered file:
Accidentally delete the files that were selected in another directory: