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

Unable to use additional plugins in the themes #4

Closed
choovick opened this issue Dec 28, 2024 · 2 comments
Closed

Unable to use additional plugins in the themes #4

choovick opened this issue Dec 28, 2024 · 2 comments

Comments

@choovick
Copy link

choovick commented Dec 28, 2024

Happy holidays, and thank you for the amazing plugin—there are literally dozens of us using it! 😆

I finally found some time to report and provide a workaround for a small annoyance I encountered.

Use case: I wanted to fancy up my theme using this plugin: https://github.com/MunifTanjim/tmux-mode-indicator.

Issue: The script switches themes by sourcing only the theme files and then creating a symlink. I noticed that my TMP is working on the initial TMUX load, but after triggering notify, #{tmux_mode_indicator} becomes empty.

Workaround steps:

  1. Update tmux-theme-mode.sh to load .tmux.conf instead of only the theme file. Additionally, creating the symlink before triggering the source helps fix the missing $TMUX_THEME_LINK file earlier.

    diff --git a/scripts/tmux-theme-mode.sh b/scripts/tmux-theme-mode.sh
    index 167a875..2789e89 100755
    --- a/scripts/tmux-theme-mode.sh
    +++ b/scripts/tmux-theme-mode.sh
    @@ -50,8 +50,8 @@ tmux_set_theme_mode() {
                    echo "The configured theme is not readable: $theme_path" >&2
                    exit 2
            fi
    -       tmux source-file "$theme_path"
            ln -sf "$theme_path" $TMUX_THEME_LINK
    +       tmux source-file "$HOME/.tmux.conf"
     }
  2. Change the initialization order in the .tmux.conf.

    Here's how I do it: https://github.com/choovick/.dotfiles/blob/main/stow/tmux/.tmux.conf#L140.

    # dark-notify themes
    set -g @plugin 'erikw/tmux-dark-notify'
    set -g @dark-notify-theme-path-light '$HOME/.tmux/tmux-gruvbox-light.conf'
    set -g @dark-notify-theme-path-dark '$HOME/.tmux/tmux-gruvbox-dark.conf'
    # dark by default
    if-shell "test ! -e ~/.local/state/tmux/tmux-dark-notify-theme.conf" \
        "source-file $HOME/.tmux/tmux-gruvbox-dark.conf"
    # dark notify theme is it was triggered
    if-shell "test -e ~/.local/state/tmux/tmux-dark-notify-theme.conf" \
        "source-file ~/.local/state/tmux/tmux-dark-notify-theme.conf"
    
    # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
    run '~/.tmux/plugins/tpm/tpm'
    • TPM remains at the end, as we’re re-sourcing the entire config.
    • The MunifTanjim/tmux-mode-indicator plugin now works with the theme.
    • if-shell "test ! -e ~/.local/state/tmux/tmux-dark-notify-theme.conf" ensures the default theme is used on the first launch if the symlink is not present; otherwise, the symlink will be used.

Risk: I’m not sure if it’s still an issue, but I’ve heard that re-sourcing .tmux.conf can cause problems with some plugins. However, I haven’t encountered any yet.

This is my approach to resolving the issue, but I’m open to additional suggestions on incorporating other plugins into themes.

@erikw
Copy link
Owner

erikw commented Dec 28, 2024

Hello, and thank you for looking in to this.

Yes I think that recall that I wanted to avoid resourcing the whole tmux.conf. I light have experienced some issues myself either plugins, or to make the plugin more snappy (can take some time to resource if it’s a complex setup).

I will be unable to look closer at this still for a while. Until then, feel free to have a fork with the fix that works for you:)

@choovick
Copy link
Author

Ok I think I have found a simpler workaround! Not sure why I did not think of that before...

choovick/.dotfiles@222cf27

basically run '~/.tmux/plugins/tpm/tpm' at the end of the theme seems to do it as well!

As I maintain my own copy of the theme in my stow repo, this will work will less complications for me. Thx again for amazing plugin. Really helps when I need to work outside under the sun using light desktop while dark inside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants