o0th / tmux-nova

tmux theme
MIT License
173 stars 20 forks source link

Cannot add right segment for 'tmux-prefix-highlight' #33

Closed louis-hsu closed 1 year ago

louis-hsu commented 1 year ago

Hi, the theme is simple and elegant with versatile customization capability. Nevertheless encounter one issue when applying one 3rd tmux plugin.

Setup in .tmux.conf

  1. Use TPM for tmux plugin management/installation and configure nova theme as

    set -g @plugin 'o0th/tmux-nova' 
    
    set -g @nova-segment-novatime "%Y-%m-%d %H:%M"
    set -g @nova-segments-0-right "novatime whoami"

    And the result shown as:

    ScreenShot 2023-04-13 at 09 12 37
  2. Then install 'tmux-prefix-highlight' and add to right segment

    set -g @plugin 'o0th/tmux-nova'    
    set -g @plugin 'tmux-plugins/tmux-prefix-highlight' 
    
    set -g @nova-segment-novatime "%Y-%m-%d %H:%M"
    set -g @nova-segment-actionprefix "#{prefix_highlight}"
    set -g @nova-segments-0-right "actionprefix novatime whoami"

Symptom

  1. Click prefix + I to install the pluging/configuration via TPM, the segment shows:

    ScreenShot 2023-04-13 at 09 47 46
  2. Click prefix + U to update the plugin/reload configuration via TPM, the segment restores to original presentation:

    ScreenShot 2023-04-13 at 09 12 37
  3. Type tmux source ~/.tmux.conf in the session, the segment doesn't change.

  4. Click prefix, the expected 'prefix-highlight' segment doesn't show up

  5. Quit tmux session, kill tmux server and restart a new session, the right segment shows as original one and no 'prefix-highlight' segment shows up when clicking prefix

Please let me know if futher test/info required, and thanks for your assistance.

arrrgi commented 1 year ago

@louis-hsu - I think the issue may be with the 'tmux-prefix-highlight' plugin, I tried another official plugin 'tmux-plugins/tmux-cpu' and this worked fine when I added it to @nova-segments-0-right with "cpu whoami"

Sadly, the prefix plugin is no longer maintained.

arrrgi commented 1 year ago

Perhaps @o0th you could add this feature into tmux-nova directly using the newer syntax. I'm not comfortable enough on the changes required to make this work for a PR sorry. Best left to the experts 😄

o0th commented 1 year ago

Hi @louis-hsu, thank you for opening this issue! Apparently, tmux-prefix-highlight is incompatible with tmux-nova. I could make it work by changing a few lines in the plugin source code, but I was not too fond of the general behavior.

@arrrgi: I think it is possible to have a similar implementation without touching the source code tmux-nova and without writing a plugin

set -g @nova-segment-action-prefix "#{?client_prefix,^B,}#{?#{==:#{pane_mode},copy-mode}, ^C,}#{?#{==:#{pane_mode},view-mode}, ^V,}"

Let me know what you think about it!

arrrgi commented 1 year ago

Thanks @o0th set -g @nova-segment-action-prefix "#{?client_prefix,^B,}#{?#{==:#{pane_mode},copy-mode}, ^C,}#{?#{==:#{pane_mode},view-mode}, ^V,}" worked.

I wonder if you also know how I get the status to show if the panes are in sync mode with this? (currently I have this bound as Prefix + Ctrl X)

o0th commented 1 year ago

Adding #{?synchronize-panes,^S,} to the @nova-segment-action-prefix will do :)

arrrgi commented 1 year ago

Thanks, worked great!

louis-hsu commented 1 year ago

Hi @o0th and @arrrgi , thanks for the help and it works! Nevertheless, found anothe symptom after following suggestion to set new right segment for prefix (with minor tweaks):

  1. Pressing prefix ScreenShot 2023-04-18 at 20 51 31
  2. Pressing bound key (mine is Esc) to enter Copy mode ScreenShot 2023-04-18 at 20 54 08
  3. Then pressing prefix again ScreenShot 2023-04-18 at 20 54 55

The similar symptom for synchronization mode

I tried to trace tmux-prefix-highlight source code to see how to reload the segment correctly but no clue yet...

o0th commented 1 year ago

Hi @louis-hsu, sorry for the waiting time; I could not dedicate time to this till now. You could try this:

set -g @nova-segment-action-prefix "#{?client_prefix,^B,#{?#{==:#{pane_mode},copy-mode},^C,}#{?#{==:#{pane_mode},view-mode},^V,}#{?synchronize-panes,^S,}}"
louis-hsu commented 1 year ago

Hi @o0th, it works! Thanks a lot!