I am trying to save a buffer to a file. In the name of the file I want to use the pane id. I use the following tmux command.

save-buffer "$TMPDIR/tmux.#{pane_id}"

This saves a file in /tmp/tmux.#{pane_id}. Other commands, like run "echo $TMPDIR/tmux.#{pane_id}", gives the desired output, i.e. /tmp/tmux.%1.

I am using tmux 2.6.

  • @thrig This will not work if the pane is busy, but it suits me wll. If you want to leave the answer so I can accept it.
    – durum
    Jun 2, 2018 at 14:08

1 Answer 1


One workaround (with caveats) is to run a command to act on the output of save-buffer and in that command use tmux variables:

bind-key s run "tmux save-buffer - > ~/tmp/tmux-#{pane_id}"

You must log in to answer this question.

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