soyuka / tmux-current-pane-hostname

Tmux plugin that enables displaying hostname and user of the current pane in your status bar.
MIT License
76 stars 23 forks source link

Conditional with pane_ssh_connected not working #12

Open cvuorinen opened 4 years ago

cvuorinen commented 4 years ago

I would like to change status line based on ssh connection, but I can't get the conditional working. First of all, I think the example in readme has incorrect variable name, shouldn't #{?#{pane_ssh_connection},ssh,no-ssh} be #{?#{pane_ssh_connected},ssh,no-ssh}?

But anyway, neither of those seem to work. They both just always display "no-ssh". And I've also tried just #{?pane_ssh_connected,ssh,no-ssh} but same result. The #U and #H interpolation work correctly, I can see the user and hostname of my ssh connection, but the conditional still displays "no-ssh". If I just put #{pane_ssh_connected} in the status, I see 1 when ssh is connected and nothing when no ssh connection. But still the conditional is not working.

Am I missing something here? I'm fairly new to tmux so I've not used the conditionals before. I'm running tmux 2.9 on Ubuntu.

soyuka commented 4 years ago

#{pane_ssh_connected} I guess you need to cast this as a boolean somehow? Could you send me a documentation PR if you manage to make this work? Tyvm.

cvuorinen commented 4 years ago

Yea, I can send a PR if I get it working. But don't have any idea ATM what to do to it, everything I have tried failed. I'm not familiar with casting to boolean in tmux conf.

terrabitz commented 4 years ago

@cvuorinen I think you need to make sure it's quoted properly in the format string. For example, the following works just fine for me:

set -g status-left '#{?#{pane_ssh_connected},ssh,no-ssh}'

One other thing I've found out the hard way is that format strings (like status bars) can use the conditional. You apparently can't use tmux conditionals for formatting (e.g. set -g window-style).