ofirgall / tmux-window-name

A plugin to name your tmux windows smartly.
MIT License
213 stars 22 forks source link

Leverage user options and hooks to avoid overriding user-defined window names #11

Closed Frederick888 closed 2 years ago

Frederick888 commented 2 years ago

commit 92e5d358c8149824ec1326bca3ee3549d5d1a2eb

Track user-defined names with Tmux user option

A Tmux user option @tmux_window_name_enabled (by default 1) is added,
and an after-rename-window hook clears it in current window.

So when a user renames a window, the option is cleared. When we rename
windows, we temporarily remove the hook and add it back when we finish.

commit e6524d768516d270be2ef232b0944ce708416898

Implement a guard to avoid racing

Otherwise when our process is running, another process may be about to
finish and adds the hook back, and later window renaming in our process
will trigger the hook and remove @tmux_window_name_enabled
unintentionally.

commit ca10769a2c452698e42176833c4a29e8187dc61d

Add binding <prefix>" to enable tmux-window-name

commit 2c69b6a832f0e0c750055dfa524603dd9d0e4a35

Fix quoting to avoid word splitting

The second argument actually consisted of three strings:

- "run-shell"
- $CURRENT_DIR/scripts/rename_session_windows.py
- ""

Second try :P

ofirgall commented 2 years ago

I forgot about tmux-continuum, it rename the windows on restore, we need remove the rename-hook in @resurrect-hook-pre-restore-all

Frederick888 commented 2 years ago

I forgot about tmux-continuum, it rename the windows on restore, we need remove the rename-hook in @resurrect-hook-pre-restore-all

I'm not familiar with tmux-continuum. Could you help with this issue?

ofirgall commented 2 years ago

@Frederick888 Thanks for the contribution, I made some changes to my taste. The main change is the default value of _enabled is now set to 1 instead of 0