0

I have a bash script that sets a variable:

tmux setw @tmux_man_pane $pane

When the bash function that uses this variable is called for the first time, I get:

unknown option: @tmux_man_pane

I put this in .tmux.conf:

setw -g tmux_man_pane 0

setw -g tmux_cheat_pane 0

But still getting the error.

Code for context:

tmux_man_page() {
  if [[ "$TERM" =~ 'screen' ]] && [[ -n "$TMUX" ]]; then

    pane=$(tmux showw -v @tmux_man_pane)
    output=$(tmux list-panes -t ${pane} 2>&1)

    if [[ $pane ]] && ! [[ -z "$pane" ]] && ! [[ $output =~ 'find pane' ]]; then
      tmux -q respawn-pane -k -t $pane man $1
    else
      tmux split-window -vf man $1
      pane=$(tmux display-message -p "#{pane_id}")
      tmux setw @tmux_man_pane $pane
      tmux select-pane -t {last}
    fi
  fi
}
  • Which line causes the error? – ctrl-alt-delor Apr 13 at 13:52
  • I would assume it's the pane=$(tmux showw -v @tmux_man_pane). It's complaining the variable isn't set. It's not a bash error. It's a tmux error. – StevieD Apr 13 at 13:56
1
  • Change command from showw to show-options
  • Use -w switch for window option
  • use -q switch for quiet option to suppress errors from unset variables

So command is now:

show-options -vwq @tmux_man_pane

1

showw and show -w are exactly the same.

The problem is the option doesn't exist yet, best bet is to add -q as suggested or otherwise handle the error in the script.

If you want to set an initial value it is no use doing so in .tmux.conf (even if you used the right name for the option!) because the window won't exist yet, you would need to do it using one or more of the hooks (maybe window-linked). I'd recommend just handling the not-yet-set error in your script though.

  • I found the that -q command did not work on showw. I had to change the command to show-options. – StevieD Apr 15 at 0:43
  • Oh you are right, it was never added. – Nicholas Marriott Apr 15 at 6:39

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.