How can I write all the scrollback in a tmux session to a file?capture-panel  can grab the current screen, but not the entire scrollback.
Write all tmux scrollback to a file
tmux
This depends on the value of history-limit that you have set in your .tmux.conf - the default is 2000; if you wish to capture more, you will need to explicitly set the number of lines.To capture the entire scrollback, enter copy mode, select the entire scrollback, and yank it into the buffer, then paste it into your file.How you accomplish this will depend on the mode-keys option you prefer, vi or emacs. man tmux has a helpful table describing the respective keys.I have the following in my .tmux.conf to simplify this:unbind [bind Escape copy-modeunbind pbind p paste-bufferbind-key -t vi-copy 'v' begin-selectionbind-key -t vi-copy 'y' copy-selectionThe process for capturing the full scrollback is then:PrefixEsc : to enter copy modev : to begin visual selection (assuming you are already at the bottom of the screen)gg : to capture everything in the scrollbacky : to yank it into the bufferPrefixc : open another tmux windowvim scrollback.txti : enter insert mode in vimPrefixp : paste into fileThere is also an answer here describing how to copy the buffer to a temporary file using xsel that might be useful.