Home > howto > Capture tmux output – the much less painful way

Capture tmux output – the much less painful way

Before I found out this, I had to enter scrolling mode, using mouse to select/copy content to system clipboard. Those days have gone as the following will definitely speed things up a lot:

1) tmux a
2) ^b [
3) ^ space
4) move cursor with arrow keys and/or pageup/pagedown keys
5) ^ w
6) ^b ]
7) ^b:
8) save-buffer ~/out_file

Explanations:
2) enters copy mode
3) starts the selection
5) copies to buffer (0)
6) ends copy mode
7) enters tmux command line mode
8) use this command to save buffer (0) to file ~/out_file, specify with option [ -b buffer-index ] if needed, tmux command list-buffer will show the buffer list

Have fun!

Sources:
http://cheasy.de/tmux.pdf
http://www.openbsd.org/faq/faq7.html [ scroll to page buttom, section “Advanced tmux usage” ]

Categories: howto
  1. Tharun
    November 30, 2011 at 3:19 pm

    excellent .. superb..

  2. isomorphismes
    July 11, 2012 at 9:42 pm

    Do you know if there’s a way to paste a whole file into the tmux buffer? As in pbcopy < filename or xsel -b < filename but more like tmuxbuf < filename?

  3. echobravo2
    February 22, 2015 at 5:06 am

    is there a way to capture tmux output via command line?

  4. echobravo2
    February 22, 2015 at 5:43 am

    ok, found:
    tmux bind-key S capture-pane \; save-buffer ~/file.txt

  5. echobravo2
    February 22, 2015 at 6:50 am

    of course we need to set the buffer first:

    tmux set-buffer ~/file.txt
    tmux bind-key S capture-pane \; save-buffer ~/file.txt

  1. March 21, 2016 at 11:00 am

Leave a comment