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

Getting error when adding the plugin #1

Closed farzadmf closed 2 years ago

farzadmf commented 2 years ago

Hi, I tried installing the plugin using tpm, however, when I do <prefix> I to install, tpm is returning 1

I tried enabling some "logs" in tpm scripts, and it seems that when sourcing tmux-modal.tmux, it's giving an error:

unknown key: "M-#"

I don't see any mention of this in the tmux file, so I was wondering if you could help me figure out what's happening

whame commented 2 years ago

Hm that's weird. Can you paste your .tmux.conf?

farzadmf commented 2 years ago

@whame my tmux.conf is a bit large. I was hoping you'd have a clue as to where (and why) this might be happening so that I can focus there.

I'll try to investigate more to see if I can find something helpful I can share


UPDATE: upon further investigation, it seems like this is the line causing the error:

unbind "^bind-key +-T +$KT_PREFIX-"

It seems like commenting that line out enables the plugin features (M-m will display = in the status bar), however I'm not sure if that would cause some features not working if I disable that line 🤔

whame commented 2 years ago

Ok, let's try to work with what we got instead then. I'm guessing you didn't play with tmux-modal before installing it through TPM, right? I.e. hacking the files etc.

One way to test this would be to reinstall the plugin:

  1. Remove set -g @plugin 'whame/tmux-modal' in tmux.conf
  2. Hit prefix + Alt + u to uninstall with TPM
  3. Add set -g @plugin 'whame/tmux-modal' in tmux.conf
  4. Install with prefix + I

Does this work? If not, could you paste the output of

tmux lsk

after step 2?

winstonCodes commented 2 years ago

The solution here resolved my issue:
https://github.com/tmux-plugins/tpm/blob/master/docs/tpm_not_working.md

Basically you need to reformat the way you are calling your plugins

from:

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'whame/tmux-modal'

to:

set -g @plugin '
    tmux-plugins/tpm               \
    tmux-plugins/tmux-resurrect    \
    whame/tmux-modal               \
    '

This is a bug with tpm related to sourcing custom configs

farzadmf commented 2 years ago

@winstonCodes , from the link you sent, I see the format seems to be set -g @tpm_plugins, and when I do set -g @plugin, that doesn't seem to install any of the plugins

Trying with @tpm_plugins doesn't solve the issue either 🤔

farzadmf commented 2 years ago

@whame

Does this work?

Doesn't seem to change anything unfortunately 🙁

Also, the output of tmux lsk for me is 747 lines long, not sure if it would be useful to paste all that. Maybe I can search for something and put the results here. (Of course I can include all 747 lines if you think is useful)

whame commented 2 years ago

I actually think it might be useful. You could just attach it here as a file, e.g.

tmux lsk > lsk.txt

Because if it is line https://github.com/whame/tmux-modal/blob/master/tmux-modal.tmux#L299 that is the offending one, the output might give some clues. I do have some other options I would like to try also, but let's try with this one first!

farzadmf commented 2 years ago

Hey @whame , sorry for the delay,

So this is my lsk without tmux-modal in my list of tpm plugins

lsk.txt

whame commented 2 years ago

The output did indeed help! There was some edge cases that we hadn't covered here. In short, special (tmux) characters such as # and " are reported in quotes (or escaped) in tmux list-keys, and they are not directly accepted in tmux unbind-key (e.g. unknown key: "M-#"). We therefore need to handle them specifically (see the commit message for more details).

I just pushed the fix. Please update and test (for TPM, hit prefix + U).

This was a fun bug. Thank you very much for your cooperation!

farzadmf commented 2 years ago

Nice!!! 🚀 🚀 🚀 glad that I could help, and thank you for not giving up and following up

...

However, sorry to spoil things, but now I'm getting an error saying:

unknown key: M-\\
whame commented 2 years ago

This was trickier than I thought! Your config is quite comprehensive and is actually a very good test :)

Not only do we have to take care of quotes but also characters that tmux reports as escaped (with backslash) and semicolons that are treated differently as well. However, hopefully we have covered most of the edge cases now (there are probably some odd ones left).

Please try the latest commit (again, with TPM just hit prefix + U). Hopefully we have fixed this now and can close this one.

farzadmf commented 2 years ago

@whame

Boom 🚀 seems to be working now 🎉

I will close this one, however I have a couple of suggestions. Do you want me to create a new issue or I can do it here?

(of course there are just suggestions)

whame commented 2 years ago

It would be better to create a new issue

farzadmf commented 2 years ago

Created #2 🙂