3

I'm using iTerm 2 nightly and I have the following tmux config setting for the left status bar:

set -g status-left "#[fg=green]#h @ #[fg=cyan]#(extip | awk '{print \"ip \" $1}') #[fg=yellow]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}')  #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}'"

Which is supposed to print my external IP, en0 and, if connected, my vpn connection. extip is my own tool that I wrote myself, but haven't touched in quite some time, and it works great from the command line (and I can see that it gets invoked and returns correctly when attaching a debugger to it). It all worked great until a couple of weeks ago, and since then it just displays <'extip | awk '{print "ip " $1}'' not ready> instead of my external IP address. The rest is still working perfectly without any issues. At first I thought it was just iTerm nightly being unstable, but a couple of updates have passed and it still doesn't work, so I'm feeling that maybe it wasn't supposed at all ever and just did by some kind of fluke? Can anyone give me some pointers with regards to why it may have stopped working and how I can get it to work again?

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
JustSid
  • 131
  • 4

2 Answers2

2

https://github.com/tmux/tmux/issues/733#issuecomment-277230881 mentions that

the not ready message is normal, tmux is telling you the command has not finished running yet, it will display the output as soon as the command finishes

I've been seeing this after upgrading from Ubuntu 16.04 to 16.10 with my script that shows the ssh server in window-status-format – it flashes by while connecting. In fact, I can reproduce it by just doing

tmux setw -g window-status-current-format '#(echo `tmux display-message -p "#W #{pane_pid}"`)'

and then ssh aslkfdsdkljfslkdsajf, it'll flash by while trying to connect.

I'm guessing extip takes a while to return a result; what happens if you replace it with a shell script that just does echo 1 or sleep 1; echo 1?

(Note also that tmux should cache any commands once they're executed at least once in that window/pane, but if the command itself changes – as in my example above – it won't use the cache. I've submitted a bug report about silencing the "not ready" command in such cases.)

unhammer
  • 326
  • 4
  • 13
0

I've tricked this in the past, by instantiating tmux with a rudimentary display-message command (e.g. "Welcome, $USER..."), which seems to gives it a second or so to run the external app for the first time.

Depends on your needs, of course. I start tmux in my profile script but, if you run tmux on demand, you may get away with an alias...

# /usr/bin/tmux -V
tumx 2.4
# /usr/bin/tmux new-session \; display-message "Welcome, $USER..."
jimbobmcgee
  • 422
  • 2
  • 5
  • 14