whame / tmux-modal

Execute complex tmux commands in just a few keystrokes with a modal mode that is designed to be efficient, easy to remember and comfortable
MIT License
172 stars 4 forks source link

Show feedback for key presses #2

Closed farzadmf closed 1 year ago

farzadmf commented 2 years ago

Hi,

I really like the idea of the plugin. I think it would be nice to have some kind of feedback when we press keys in the "modal mode".

For example, in vim, when you press keys, you'd see them in the status bar, and since this plugin generally uses a sequential combination of keys, it would be helpful to see what keys you have pressed.

Also, that would somehow imply a way to "cancel" you current sequence (maybe by pressing ESC or something)

Also, another suggestions to be able to press ESC to get out of the "modal" mode (in addition to the M-m combination)

As a bonus, it would be nice to have those as configurable options that we can enable/disable/change

Of course, all these are just suggestions; feel free to ignore 🙂

whame commented 2 years ago

Thank you very much for your feedback! Some very interesting points there.

I really like the idea of the plugin. I think it would be nice to have some kind of feedback when we press keys in the "modal mode".

For example, in vim, when you press keys, you'd see them in the status bar, and since this plugin generally uses a sequential combination of keys, it would be helpful to see what keys you have pressed.

This would be very nice to have (I would like that too!). However, I believe this is very hard to implement. tmux status bar is not designed to be "dynamic". I'm not even sure how one could "intercept" the keys and update the status bar during a command sequence. If you (or someone else) have an idea, please tell.

Also, that would somehow imply a way to "cancel" you current sequence (maybe by pressing ESC or something)

Actually, any "invalid" key cancels the sequence (default in tmux). For example, if you hit w s to start splitting the window and then hit q (or ESC) the command would cancel (q is "reserved" as "quit"). Maybe we need to update the README with this information...

Also, another suggestions to be able to press ESC to get out of the "modal" mode (in addition to the M-m combination)

Hm there was someone else on Reddit that I believe suggested this as well. I told them to create an issue here on GitHub, but they haven't done it. Could you please create a separate issue (labeled with "enhancement") for this? That way we can track the progress of that feature easier. Thank you!

farzadmf commented 2 years ago

Thank you very much for your feedback! Some very interesting points there.

Glad that you liked it

believe this is very hard to implement. tmux status bar is not designed to be "dynamic".

Just throwing out something here (probably stupid): can't we use the same mechanism that shows that = equal sign when the mode changes?

Actually, any "invalid" key cancels the sequence

Good to know, I guess this goes hand in hand with the feedback part; if there was a way to provide feedback, then we would clearly see that "OK, now the combination is reset"

Could you please create a separate issue

Will do in a bit -> UPDATE: created #3 (I don't think I'm able to add a label, am I?)


Also, I'm not going to close it in case anyone (we or someone else) comes up with an idea about a method to have a "realtime feedback" for key combinations, if that's OK with you

whame commented 2 years ago

Just throwing out something here (probably stupid): can't we use the same mechanism that shows that = equal sign when the mode changes?

That design works since we just track two "states" here: normal and command ("modal") mode (see https://github.com/whame/tmux-modal/blob/master/tmux-modal.tmux#L577 for some rather complex code for such a "simple" feature). For arbitrary key presses that would be extremely complex (maybe not even possible).

I believe one probably has to hack the tmux source code a bit to be able to easily "hook" in to the key press processing mechanism. As far as I know, there is no such thing today (or?).

Good to know, I guess this goes hand in hand with the feedback part; if there was a way to provide feedback, then we would clearly see that "OK, now the combination is reset"

I agree.

Also, I'm not going to close it in case anyone (we or someone else) comes up with an idea about a method to have a "realtime feedback" for key combinations, if that's OK with you

Yeah, that's fine.

farzadmf commented 2 years ago

Hey @whame , not sure if you know about it or if it's useful at all (trying blindly to find "something" 😝 )

From here, I see there's tmux refersh-client -S to refresh the status bar.

As I said, I have no idea if it's useful; just mentioning it

whame commented 2 years ago

Maybe the way we display the modal icon ([=]) is in fact the way to go... This is similar to what you are suggesting.

As I said before, it would be quite complex and would take some time to develop. This might be better suitable for a future version (if there isn't an easier way right now).

dnguyenzd commented 1 year ago

somewhat related but hopefully simpler to implement: it would be great addition if it can show different icon/character in status for what "mode" we are in, e.g. window, window resize, cmd

I think each mode at the moment has its own key table?

A thing to consider is that too many icons/characters can hurt user experience too (users can't remember all of them), so maybe only the primary modes

whame commented 1 year ago

That's a good suggestion! Indeed, the different modes do have their own key table. This might be easier to implement. Something like:

[=]    # for "root" command key table
[w]    # for window key table
[wr]   # for window resize key table
[s]    # for session key table
[g]    # for goto key table

etc.

or we can have icons, but that would probably be too difficult to remember. I like the idea of distraction free visualization. This will certainly be an option that will be off by default.

whame commented 1 year ago

This has now been implemented in master (thank you @dnguyenzd for the simpler idea!). Please try it out with:

set -g @modal-show-cmd-keys on

in .tmux.conf.

Thanks for the suggestion!

dnguyenzd commented 1 year ago

awesome, thanks a lot, it's working well