0

I've created a helper function to display a message into the current pane:

function current_pane_id {
  echo "$(tmux display -p '#{pane_id}')"
}


function display_message {
  message="$1"
  "$(tmux display-message -p -t"$(current_pane_id)" "'$message'")"
}

that is used like this:

display_message "turned display on"

The problem is that rather then pass the content of $message to to the command, it keeps trying to execute the content of $message, and it doesn't seem to matter how I try to quote it, it keeps executing it.

How do I pass the content of the variable to the command without having bash execute it?

1 Answer 1

2

That is caused by the unnecessary $(...).

function display_message {
  message="$1"
  tmux display-message -p -t"$(pane_id)" "'$message'"
}
2
  • $pane_id is a function, I'll update the OP, should have made that clearer
    – Thermatix
    Aug 15, 2018 at 11:50
  • ... likewise in the current_pane_id function.
    – Kusalananda
    Aug 15, 2018 at 13:14

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.