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

Missing conditional variable #9

Closed SimonLammer closed 6 years ago

SimonLammer commented 6 years ago

I'd like to have have a conditional right status bar like so:

If the current pane is local (no ssh): "#U #{pane_current_path}" If the current pane is an ssh connection: "#U@#H"

Currently I can't find a way to check if the current pane has an ssh connection, becuase shorthands (like "#U") are evaluated after other commands (using "#(command)") in the status bar, whereas variables (like "#{host}) are evaluated before other commands. Therefore my conditional "#{?#{==:#H,#{host}},no-ssh,ssh}" always evaluates to "no-ssh", because it compates "#H" (which has not been evaluated at the time) to the value of "#{host}", which is "my-laptop".

I would like to have an conditional variable (e.g.: "pane_ssh_connected") that can be used to make a conditional like that: "#{?pane_ssh_connected,ssh,no-ssh}".

SimonLammer commented 6 years ago

It should work if the variable (e.g.: "pane_ssh_connected") had a value of "0" if no ssh connection is active and a value of "1" if there is an active ssh connection.

soyuka commented 6 years ago

I'd like to add this, may you propose a patch?

SimonLammer commented 6 years ago

I've been looking for about an half hour and couldn't figure out how I'd go about this (since I don't have any experience in tmux plugin development), so I wanted to check If you had any Ideas, before I continue going down the rabbit hole.

SimonLammer commented 6 years ago

I'm implementing this. A PR will be opened once I make progress.