In tmux, how do I create a function that will set a variable that will then be available to use within tmux pane border status:

set -g pane-border-format

so I can then run that function and have the value set but only for that pane and nowhere else so that the border status displays something different for that pane and if I run that function in another pane, the pane border status will display something else but only for the pane that the function was runin

so if I run the function in pane 1 to say 'hello world' then in pane 2 to say 'goodby world' I expect pane 1 border status to say 'hello world' and pane 2 border status to say 'goodby world'.


I found out how to set user options, so I created a function to automate this:

if  [ -n "$TMUX" ];  then

  function set_tmux_opt {
    tmux set -q "@$1_$TMUX_PANE" "$2"


and it's used like this:

set_tmux_opt 'some_variable' '1'

and I get it like this:

function get_tmux_opt {
    tmux show -v "@$1_$2"

and used like this:

get_tmux_opt 'some_variable' $pane_id

and then passed into the script using pane_id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.