kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.4k stars 150 forks source link

[Feature request] Titles for keymap commands #373

Closed Beethoven-n closed 1 year ago

Beethoven-n commented 1 year ago

i'd like to have titles or comments on keymap commands, that way it's easier to tell the difference between them when you have a list of possible commands.

for example, my config adds dragon-drop support, but all the commands look exactly the same, except for the end.

keymap = [
# dragon-drop support
  { keys = [ "g","n","n" ], command = "shell dragon-drop --thumb-size 448 --and-exit --icon-only --on-top %s" },
  { keys = [ "g","n","a" ], command = "shell dragon-drop --thumb-size 448 --and-exit --icon-only --on-top %s --all" },
  { keys = [ "g","n","i" ], command = "shell dragon-drop --thumb-size 448 --and-exit --icon-only --on-top %s --target" },
  { keys = [ "g","n","t" ], command = "shell dragon-drop --thumb-size 448 --and-exit --icon-only --on-top %s --target" },
]

this shows up in common usage in a way that's relatively hard to read. image it's also kinda annoying that it's automatically alphabetically sorted, instead of being sorted in the way i entered it, but that's out of scope for this issue.

what might fix this is if the user was allowed to add a title to these commands that shows up instead of the command used.

xfzv commented 1 year ago

Agreed. Something like:

- { keys = [ "my_key" ], command = "shell my_command %s" },
+ { keys = [ "my_key" ], command = "shell my_command %s", description = "my_description" },

would be nice.

kamiyaa commented 1 year ago

Yeah, thats a neat idea. I like it. Have an optional description. If no description, resort to default.

kamiyaa commented 1 year ago

541f16850e33145ff657211e43a12f2327f188a6

20230812-155208_swappy 20230812-155222_swappy

xfzv commented 1 year ago

@kamiyaa Any chance the custom descriptions could be displayed in the help menu as well?

kamiyaa commented 1 year ago

@kamiyaa Any chance the custom descriptions could be displayed in the help menu as well?

Did you have any use cases in mind for this? But yes, I can add it in as well

xfzv commented 1 year ago

@kamiyaa Any chance the custom descriptions could be displayed in the help menu as well?

Did you have any use cases in mind for this? But yes, I can add it in as well

I think the current implementation is fine for commands that require a sequence of keys but unless I'm mistaken, there's no way to see the descriptions of keybindings that require a single key. I have the following:

image

In this case, my scripts names are explicit and I know what they are doing anyway, but it would be nice if we could search in the help menu using words that match the custom descriptions.

Plus, having the same descriptions in command line / help menu feels more coherent to me.

xfzv commented 1 year ago

Thank you, all good with https://github.com/kamiyaa/joshuto/commit/82e231ac004e1f25f0a447bc601e5e3a10dca4d2

image