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” ]
excellent .. superb..
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?
The answer is yes and it’s pretty easy:
load-buffer path
or
loadb path
for short
found it from
http://www.openbsd.org/cgi-bin/man.cgi?query=tmux&sektion=1
Awesome! Thanks!
is there a way to capture tmux output via command line?
ok, found:
tmux bind-key S capture-pane \; save-buffer ~/file.txt
of course we need to set the buffer first:
tmux set-buffer ~/file.txt
tmux bind-key S capture-pane \; save-buffer ~/file.txt