gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.79k stars 3.36k forks source link

tpm update plugins doesn't work since b17d57f #631

Closed Frederick888 closed 1 year ago

Frederick888 commented 1 year ago

Steps to reproduce

FROM archlinux

WORKDIR /root
RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm tmux awk perl sed git curl python vim
RUN git clone https://github.com/gpakosz/.tmux.git
RUN ln -s .tmux/.tmux.conf
RUN curl -o ./.tmux.conf.local https://git.tsundere.moe/Frederick888/frederick-settings/-/raw/master/.tmux.conf.local

Build the image then run with podman/docker run --rm -it <image> bash.

In the container, run tmux, then <prefix> + U (this is my binding for tpm's update_plugins script; prefix is Ctrl-a), tpm displays an empty list of plugins.

Workaround

I noticed if I revert the source .tmux.conf.local line, i.e.

diff --git a/.tmux.conf b/.tmux.conf
index cd065a4..8f38db8 100644
--- a/.tmux.conf
+++ b/.tmux.conf
@@ -156,9 +156,9 @@ bind P choose-buffer    # choose which buffer to paste from
 %if #{==:#{TMUX_CONF_LOCAL},}
   run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF_LOCAL "$TMUX_CONF.local"'
 %endif

-run '"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"'
+source -q ~/.tmux.conf.local
 run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'

 # EOF
 #

...then the issue is gone. No idea why though. I also tested source -F '#{TMUX_CONF_LOCAL}' but the issue persisted.

It seems somehow it just has to be ~/.tmux.conf.local (or $HOME/.tmux.conf.local).

I'm using tmux 3.3a btw.

Frederick888 commented 1 year ago

Ohhh, I think it's [1]!

If I patch the file with

diff --git a/scripts/helpers/plugin_functions.sh b/scripts/helpers/plugin_functions.sh
index f33d215..3badce9 100644
--- a/scripts/helpers/plugin_functions.sh
+++ b/scripts/helpers/plugin_functions.sh
@@ -44,8 +44,9 @@ _tmux_conf_contents() {
 }

 # return files sourced from tmux config files
 _sourced_files() {
+   echo '~/.tmux.conf.local'
    _tmux_conf_contents |
        sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
 }

...then it's working again.

[1] https://github.com/tmux-plugins/tpm/blob/99469c4a9b1ccf77fade25842dc7bafbc8ce9946/scripts/helpers/plugin_functions.sh#L49

Frederick888 commented 1 year ago

I can use source -F '#{TMUX_CONF_LOCAL}' with https://github.com/tmux-plugins/tpm/pull/244

gpakosz commented 1 year ago

Something's not quite right.

By now Oh My Tmux! sets @tpm_plugins before invoking TPM. Specifically to avoir TPM having opinion on what configuration files are and how they're sourced.

For now I can't reproduce on macOS and I don't have Docker Desktop installed.

gpakosz commented 1 year ago

But now that I think about it, you may be facing a binding clash

Can you please run the following command within a tmux pane?

$ tmux lsk | grep ' U '
bind-key    -T prefix       U                    run-shell "cut -c3- '#{TMUX_CONF}' | sh -s _urlview '#{pane_id}'"

This is the default binding for U and you're trying to set it to something else. Please revert your patches and try this in your .local customization file

bind U run-shell $HOME/.tmux/plugins/tpm/bindings/update_plugins #!important
gpakosz commented 1 year ago

Please revert to a clean state, make sure you remove everything for good mesure and try the gh-631 branch

Frederick888 commented 1 year ago

Reverted my patches and with my current .tmux.conf.local:

$ tmux lsk | grep ' U '
bind-key    -T prefix       U                    run-shell /home/frederick/.tmux/plugins/tpm/bindings/update_plugins

And if I use bind U run-shell $HOME/.tmux/plugins/tpm/bindings/update_plugins #!important, still without any of my own oh-my-tmux or tpm patches:

tmux lsk | grep ' U '
bind-key    -T prefix       U                    run-shell /home/frederick/.tmux/plugins/tpm/bindings/update_plugins

<prefix> + U still shows an empty list

gpakosz commented 1 year ago

Please also make sure your U binding is the proper one

Frederick888 commented 1 year ago

I don't see the gh-631 branch. Did you push?

gpakosz commented 1 year ago

Now it's pushed!

Frederick888 commented 1 year ago

Yes it works! Also tested my original one without #!important, worked too!

gpakosz commented 1 year ago

Nice. Maybe your TPM PR is useful to upstream but I didn't want to wait for such sort of adoption.

I'll close this with merging gh-631. Thanks for the proper investigation. Appreciated!