0

I'm trying to use a shell variable in Tmux to configure some settings for the venerable powerline. The line of interest in my .tmux.config is:

run-shell "powerline-daemon -q"
source-file $POWERLINE_ROOT/powerline/bindings/tmux/powerline.conf

I get the following error :

/Users/myname/.tmux.conf:47: /powerline/bindings/tmux/powerline.conf: No such file or directory

It seems that the value of the environment variable $POWERLINE_ROOT is not being seen by Tmux. (I can confirm that $POWERLINE_ROOT does have a non-empty value.)

You can see my complete Tmux configuration if needed

jlconlin
  • 14,206
  • 22
  • 72
  • 105
  • How are you confirming that `POWERLINE_ROOT` is non-empty? I can confirm that I can use environment variables in my `.tmux.conf` file, so it's not set when your conf file is being used. – jeremysprofile Nov 04 '19 at 22:42
  • To ensure that the variable is non-empty I can do `echo $POWERLINE_ROOT`. However, that only tells me that it is set in bash. I really don't know how to ensure its value in Tmux. I would hope that there is an "echo" function that can be done in the configuration, but I don't know what that is. – jlconlin Nov 05 '19 at 13:36
  • You appear to know about `run-shell`. You could use that to echo to a file to show that it isn't set. As for setting the variable, I believe setting it in the shell that you call tmux from should work (setting it, then starting a tmux session); I don't think setting it inside a tmux window/pane will do what you want. – jeremysprofile Nov 05 '19 at 16:49
  • @jeremysprofile You assume too much of my expertise. I only know about `run-shell` because I copied it from someone else. That being said, I did use it to write the variable to a file as you suggested. The variable was not set. However, it is set in the shell before I start Tmux so I'm not sure what is going on. – jlconlin Nov 05 '19 at 18:02

1 Answers1

1

Here's all I know:

I have the following in my .bashrc:

export __tmux_bg_inactive='234'
export __tmux_bg_active='233'
export __tmux_fg_inactive='245'
export __tmux_fg_active='248'

I have the following in my .tmux.conf:

set -g window-style "fg=colour${__tmux_fg_inactive},bg=colour${__tmux_bg_inactive}" 
set -g window-active-style "fg=colour${__tmux_fg_active},bg=colour${__tmux_bg_active}" 
set -g pane-active-border-style "fg=colour$__green, bg=colour$__tmux_bg_active"
set -g pane-border-style "fg=colour$__tmux_fg_inactive, bg=colour$__tmux_bg_inactive"

This works for me. Maybe the fact that I've export'd the variable is what did it, or maybe it's that it's in my .bashrc so it gets set everywhere tmux could possibly need it?

Let me know if that doesn't work.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
  • I've done the same thing; that is, I export the variables in my `.bashrc` and then I try to use them in `.tmux.conf`. After Tmux starts (with the error), I can `echo $POWERLINE_ROOT` in the shell and I see that it has an appropriate value. I can also do `:source-file $POWERLINE_ROOT/powerline/bindings/tmux/powerline.conf` in Tmux after it starts and still get the same error. – jlconlin Nov 05 '19 at 19:39
  • BTW, I like your name (same as mine!) – jlconlin Nov 05 '19 at 19:40
  • you exported the variables in your bashrc, then sourced your bashrc, then started tmux? – jeremysprofile Nov 05 '19 at 19:50
  • I thought I had exported, but now that I double check my configuration I forgot the little `export` word. ``Sorry for making you do all this when I'm just being dense.`` – jlconlin Nov 05 '19 at 20:05