1

in my tmux.conf I want to incorperate a reminder to install 'tmux plugin manager' if it isn't already installed.

Therefore I came up with this in my tmux.conf:

if-shell '[ ! -d "$HOME/.tmux/plugins/tpm" ]' \
    "display-message -p 'TMUX PLUGIN MANAGER is not installed\n Install with: git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"

When now starting tmux, without the plugin manager installed I get this:

/home/user/.tmux.conf:95: no current target
'~/.tmux/plugins/tpm/tpm' returned 127

It seems to me the issue here is, that I try to display a notification before I'm attached to a session, which could display the message.

Are there any known workarounds or alternatives for this?

norman
  • 67
  • 5

1 Answers1

0

The issue you're having is that tmux already has a built in warning that the package manager is not installed (the error you came across):

/home/user/.tmux.conf:95: no current target '~/.tmux/plugins/tpm/tpm' returned 127

So when you run your code, you get that error in your if statement. Instead of an if statement, try a || statement like listed in this SO post: try-catch in bash

Keith Lyons
  • 422
  • 4
  • 12