0

When I start tmux, I get a failure when trying to configure powerline. I have set an environment environment variable with this:

export POWERLINE_CONFIG_COMMAND=`which powerline-config`

My ~/.tmux.conf contains the following:

if-shell "POWERLINE_CONFIG_COMMAND" \
  run-shell "$POWERLINE_CONFIG_COMMAND tmux setup"

The error I get is:

unknown command: /path/to/powerline-config

I can run the config command manually after tmux starts with this:

$POWERLINE_CONFIG_COMMAND tmux setup

I don't understand why tmux can't run the command during the startup when it can run just fine afterwards.

jlconlin
  • 14,206
  • 22
  • 72
  • 105

1 Answers1

1

I don't understand how you get that error. You should not get any message, and nothing should work.

if-shell "POWERLINE_CONFIG_COMMAND" \
  run-shell "$POWERLINE_CONFIG_COMMAND tmux setup"

will fail, because POWERLINE_CONFIG_COMMAND is not a command. Your if-shell should have a $ in front of POWERLINE_CONFIG_COMMAND.

Let's assume that was a typo, and it's correct in your actual .conf. Then, the problem is that run-shell runs against tmux, the way it'd run if you typed <prefix>: in your tmux session.

tmux $POWERLINE_CONFIG_COMMAND tmux setup is not a valid command.

You could instead do

   run-shell 'send-keys "$POWERLINE_CONFIG_COMMAND tmux setup" Enter'

If you wanted it run in a single pane.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
  • Your assumption is correct that I had a typo. So I tried what you suggested (`run-shell 'send-keys "$POWERLINE_CONFIG_COMMAND tmux setup" Enter'`) and got the error: `.tmux.conf:58: no current target`. So something isn't quite matching up. I really just want Powerline configured properly for my tmux set up. – jlconlin Jan 30 '20 at 18:38
  • If you reload your tmux.conf after you enter a tmux session, does it work? – jeremysprofile Jan 30 '20 at 18:59
  • Yes it does. What does that tell us? – jlconlin Jan 30 '20 at 19:00
  • It tells us that `tmux.conf` gets executed before you have any tmux sessions available, and that calling `powerline-config tmux setup` is the wrong way to start powerline for tmux. [This issue](https://github.com/powerline/powerline/issues/1566) seems to imply you're supposed to be calling `powerline-daemon` (maybe in your `.bashrc`?) and that will set up tmux stuff for you... maybe. I don't know anything about powerline. – jeremysprofile Jan 30 '20 at 19:08
  • Ok, now I think I understand a little better. I was calling `powerline-daemon` in my `.bashrc`. I read somewhere that I needed to do that. Perhaps I don't. I've changed my `.bashrc` so that now I call `powerline-config tmux setup` and things seem to be working. – jlconlin Jan 30 '20 at 19:19
  • I think you *are* supposed to run `powerline-daemon` in your `.bashrc`. I *thought* that would just magically work for `tmux` once it detected you were in that environment, and that you didn't need an explicit call to `powerline-config tmux setup` more than once ever. If that didn't work, and running both or just the latter in your `.bashrc` did, then I guess we're good? – jeremysprofile Jan 30 '20 at 19:51