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

new-window -c '#{pane_current_path}' binding is replaced with only new-window #514

Closed
shubidubapp opened this issue Sep 10, 2021 · 11 comments

Comments

@shubidubapp
Copy link

shubidubapp commented Sep 10, 2021

This was also mentioned at another issue (262) it has been more then 2 years since it was closed so I have decided to bring this in a new issue. No need to send a notification to original issue author since they solved their problem.

It seems like we still can not have different bindings new-window with or without -c '#{pane_current_path}' as configuration removes the -c binding and re adds it if tmux_conf_new_window_retain_current_path is true.

Now I would like to have 2 bindings where one of them retains the current path and the other one doesnt. I can only think of one solution which is to find and disable perl code where it removes the current path option. Which is a solution that only works for me. So as gpakosz mentioned in the issue 262, we need a way to protect bindings. A solution that comes to my mind is altering the perl regex(? im not sure what they are called) where it will not match if a binding has a certain change.

This should be the original regex where it matches with any binding as long as it has -c "#{pane_current_path}"
s/\bnew-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/new-window\1/g

My most instant approach was to edit it so it will not match if there are multiple "space" characters between -c and "#{pane_current_path}" so the \s+ will be only \s but it didn't work. for some reason. Are there any other work around you can suggest?

@gpakosz
Copy link
Owner

gpakosz commented Sep 10, 2021

Hello @shubidubapp 👋

This is still a limitation and I have no proper solution for protecting some bindings.

I'll give it more thought.

@gpakosz
Copy link
Owner

gpakosz commented Oct 3, 2021

Hello @shubidubapp 👋

Can you please try the gh-514 branch that allows you to set the following configuration variables to disabled

  • tmux_conf_new_window_retain_current_path
  • tmux_conf_new_pane_retain_current_path
  • tmux_conf_new_pane_reconnect_ssh
  • tmux_conf_new_session_prompt
  • tmux_conf_copy_to_os_clipboard

@shubidubapp
Copy link
Author

Hello @gpakosz

Thanks for the information. I will be trying it out.

@gpakosz
Copy link
Owner

gpakosz commented Oct 11, 2021

Hey @shubidubapp 👋

Any news?

@shubidubapp
Copy link
Author

Hi @gpakosz, I was a little busy so I forgot to test it out I am only now testing it, sorry.

Screenshot from 2021-10-11 22-58-28

So I got the branch you mentioned. As you can see it is the current .tmux.conf I am using. I have "disabled" the setting that should be affecting the new-window bindings and then binded a key so I can retain the path if I use that binding. But it doesnt work and when I list the keys the binding is actually isnt in the way I am using right now. Am I missing something?

Is there anyway of debugging the piece of code that is changing the binding may be I can help?

@gpakosz
Copy link
Owner

gpakosz commented Oct 11, 2021

No worry!

I forgot to push a fixup commit to the gh-514 branch that fixes an obvious mistake in _is_disabled().

About debugging, it's a big icky but doable. What I do is replace

# _apply_bindings() {
#   cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
...

by

# _apply_bindings() {
#   cfg=/tmp/tmux.conf
#.  exec 2 >/tmp/log.txt
#.  set -x
...

And every time I reload the conf I can inspect /tmp/log.txt

@shubidubapp
Copy link
Author

Yup last commit fixed the problem and the "disabled" key is actually a pretty good idea. Thank you for the fix.

@imcaizheng
Copy link

Hi, I ran into some sort of syntax error when tmux_conf_new_window_retain_current_path is set to true. Can reproduce the error even with the latest commit of the master branch.

Removing these two lines temporarily fixed the error for me. Does anyone know the root cause of this issue?

@gpakosz
Copy link
Owner

gpakosz commented Dec 9, 2021

@imcaizheng Can you please open a separate issue in which you detail your configuration? OS? tmux version? Thanks!

@imcaizheng
Copy link

@gpakosz I open a new issue here #541

@gpakosz
Copy link
Owner

gpakosz commented Jun 12, 2022

Hello here can you please try the gh-571 branch?

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
…sz#514

you can set the following variables to 'disabled':
  - tmux_conf_new_window_retain_current_path
  - tmux_conf_new_pane_retain_current_path
  - tmux_conf_new_pane_reconnect_ssh
  - tmux_conf_new_session_prompt
  - tmux_conf_copy_to_os_clipboard
farhadkarimi pushed a commit to farhadkarimi/.tmux that referenced this issue Aug 18, 2023
…sz#514

you can set the following variables to 'disabled':
  - tmux_conf_new_window_retain_current_path
  - tmux_conf_new_pane_retain_current_path
  - tmux_conf_new_pane_reconnect_ssh
  - tmux_conf_new_session_prompt
  - tmux_conf_copy_to_os_clipboard
Rafiot pushed a commit to Rafiot/.tmux that referenced this issue Jan 24, 2024
…sz#514

you can set the following variables to 'disabled':
  - tmux_conf_new_window_retain_current_path
  - tmux_conf_new_pane_retain_current_path
  - tmux_conf_new_pane_reconnect_ssh
  - tmux_conf_new_session_prompt
  - tmux_conf_copy_to_os_clipboard
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