I'm trying to extract the remote host of a system I'm SSHing into.

tmux's pane_title variable looks like:

username@host: ~

And I tried to set the window status like:

:setw -g window-status-format ' #I:#{s/^.*@(.*):.*/\1/i:pane_title}'

But with this, the window status looks like 1:, so maybe tmux is misinterpreting the first colon?

Is there a way to escape a : in a prefix?

I tried using a backslash to escape it:

:setw -g window-status-format ' #I:#{s/^.*@(.*)\:.*/\1/i:pane_title}'

But that did not change the window status.

$ tmux -V
tmux 3.2

1 Answer 1


Option 1: Literal interpretation

An ‘l’ specifies that a string should be interpreted literally and not expanded. For example ‘#{l:#{?pane_in_mode,yes,no}}’ will be replaced by ‘#{?pane_in_mode,yes,no}’.

So your format string would use #{l::}:

:setw -g window-status-format ' #I:#{s/^.*@(.*)#{l::}.*/\1/i:pane_title}'

Option 2: ASCII codepoint substitution

‘a’ replaces a numeric argument by its ASCII equivalent, so ‘#{a:98}’ results in ‘b’.

: is ASCII 0x3A/#58, so your format string would use #{a:58}:

:setw -g window-status-format ' #I:#{s/^.*@(.*)#{a:58}.*/\1/i:pane_title}'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .