Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindings defined in .tmux.conf.local cannot override ones defined in .tmux.conf #571

Closed
kflu opened this issue May 27, 2022 · 8 comments
Closed

Comments

@kflu
Copy link

kflu commented May 27, 2022

Escape in copy-vi-mode is bound to send-keys -X cancel. I want to change it to clear-selection in .tmux.conf.local. However, it doesn't take effect

Repro

Put below in .tmux.conf.local:

bind-key -T copy-mode-vi Escape     send-keys -X clear-selection

Now completely quit and restart tmux. Then do:

tmux list-keys | grep copy-mode-vi | grep Es

Actual Result

Escape is still bound to cancel

bind-key    -T copy-mode-vi Escape               send-keys -X cancel

Expected

I expect Escape should now bound to clear-selection.

@kflu
Copy link
Author

kflu commented May 27, 2022

It looks like I'll have to wrap it with run -b 'tmux bind ... in order for it to work:

# works
run -b 'tmux bind-key -T copy-mode-vi Escape     send-keys -X clear-selection 2> /dev/null || true'

Note that, for a binding NOT defined in .tmux.conf, I can define them WITHOUT the wrap:

# works, because `copy-mode-vi q` is not defined in .tmux.conf
bind-key -T copy-mode-vi q     send-keys -X cancel

@yhshin11
Copy link

yhshin11 commented Jun 8, 2022

I'm having the same issue and found it extremely frustrating. It seems like others are experiencing the same thing, as seen in #549.

I think this might be because of something that changed on tmux's end, because I remember this working properly before. For reference, I have tmux 3.0a on my system.

What I found to work is to edit .tmux.conf so that source -q ~/.tmux.conf.local happens after run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'.

So you would edit this part like so:

# -- 8< ------------------------------------------------------------------------

run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'

# -- user defined overrides ----------------------------------------------------

source -q ~/.tmux.conf.local

@gpakosz Could you comment on if this is a valid fix, or if it's idiotic in ways that I'm not aware of?

@gpakosz
Copy link
Owner

gpakosz commented Jun 8, 2022

Hello there 👋

Can you please give the gh-571 a try?

  • It's rebased on gh-514 which means you can control whether or not Oh my tmux! alters new-window, split-window and new-session bindings
  • It should apply all bind / unbind commands found in ~/.tmux.conf.local last

@yhshin11
Copy link

yhshin11 commented Jun 9, 2022

@gpakosz Confirming that gh-571 worked for me. Thanks!

@gpakosz
Copy link
Owner

gpakosz commented Jun 11, 2022

I realized gh-514 is likely not needed so I force pushed gh-571 with a single commit on top of master.

Can you please give it another try?

@yhshin11
Copy link

@gpakosz I can confirm that this is working in master. Cheers!

@gpakosz
Copy link
Owner

gpakosz commented Jul 14, 2022

Hello again,

I changed the gh-571 branch again. Can you please give it a try?

There are 2 distinct needs that need to be addressed by Oh my tmux!

  1. People wanting to change a binding, yet still benefiting form Oh my tmux! binding manipulation.
    This is the case when you e.g. want <prefix> w to create a new window instead of <prefix> c.

    unbind c
    bind w new-window
    

    And at the same time you want to leverage tmux_conf_new_window_retain_current_path=true so that bind w new-window automatically becomes bind w new-window -c #{pane_current_path}

  2. People wanting to add additional bindings that are immune to Oh my tmux! manipulations. This is your need, and in such a case you now need to terminate your binding definition with #!important (inspired by CSS).

    bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
    

@gpakosz
Copy link
Owner

gpakosz commented Jul 16, 2022

@kflu @yhshin11

I updated .tmux.conf the sample .tmux.conf.local in the gh-571 branch. I'm testing it a bit more and I'll merge it soon

thisisrandy pushed a commit to thisisrandy/.tmux that referenced this issue Sep 8, 2022
…conf.local, closes gpakosz#571

inspired by css, any set/bind/unbind command ending with #!important will be
executed honored, e.g.:

bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
R-Broadley pushed a commit to rob-broadley/.tmux that referenced this issue Nov 20, 2022
* upstream/master:
  fixed custom variables detection, fixes gpakosz#613
  bind p to paste-buffer -p to match tmux defaults, closes gpakosz#610
  added support for wl-clipboard, closes gpakosz#589, closes gpakosz#606
  fixed <prefix>+e not working when EDITOR is set to 'emacsclient -t' and the default shell is zsh (2), fixes gpakosz#593
  fixed <prefix>+e not working when EDITOR is set to 'emacsclient -t' and the default shell is zsh, fixes gpakosz#591
  turn off history substitution in case it's been enabled (2), fixes gpakosz#583
  turn off history substitution in case it's been enabled, closes gpakosz#582
  added a way to mark set/bind/unbind commands as important in ~/.tmux.conf.local, closes gpakosz#571
  updated the weather() sample function, closes gpakosz#580
  added a way to selectively disable binding manipulation, closes gpakosz#514
  reworked pane / tty introspection (5), fixes gpakosz#573
  added RGB 24-bit colour support automatic detection
  pass #{pane_current_path} to _fpp() and then to split-window
ooosssososos pushed a commit to ooosssososos/.tmux that referenced this issue Mar 1, 2023
…conf.local, closes gpakosz#571

inspired by css, any set/bind/unbind command ending with #!important will be
executed honored, e.g.:

bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
farhadkarimi pushed a commit to farhadkarimi/.tmux that referenced this issue Aug 18, 2023
…conf.local, closes gpakosz#571

inspired by css, any set/bind/unbind command ending with #!important will be
executed honored, e.g.:

bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
Rafiot pushed a commit to Rafiot/.tmux that referenced this issue Jan 24, 2024
…conf.local, closes gpakosz#571

inspired by css, any set/bind/unbind command ending with #!important will be
executed honored, e.g.:

bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants