{"id":774,"date":"2025-10-10T11:31:12","date_gmt":"2025-10-10T03:31:12","guid":{"rendered":"https:\/\/play.datalude.com\/blog\/?p=774"},"modified":"2025-10-10T11:31:14","modified_gmt":"2025-10-10T03:31:14","slug":"copy-tmux-scroll-buffer-to-a-file","status":"publish","type":"post","link":"https:\/\/play.datalude.com\/blog\/2025\/10\/copy-tmux-scroll-buffer-to-a-file\/","title":{"rendered":"Copy tmux Scroll Buffer to a File"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">tmux is super handy for long running commands. Especially if you have a dodgy connection which is likely to break: the command will keep running and you can re-attach to the session to save the day.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But as a dyed-in-the-wool bash user, I've kinda got used to being able to scroll up and down my command history and copy items from there. But I always have to search the internet the exact commands I need in tmux. Here's an easy way to dump the whole tmux history buffer to a text file without complicated edit\/scroll\/copy start\/copy end combinations. We'll assume your tmux prefix key is the default CTRL-B<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CTRL-B  :                       # default prefix key and colon. opens the command pane, at the bottom\ncapture-pane -S -       # send whole history to tmux buffer\n\nCTRL-B   :                                              # get ready for another command, tmux\n<code>save-buffer ~\/tmux_output.txt         # self explanatory<\/code> <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can use your text editor to look at the command history, alerts, and outputs. I had to use this recently when I piped a long running script through tee -a but it failed to send any of the screen output to the specified text file. This was a lifesaver.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tmux is super handy for long running commands. Especially if you have a dodgy connection which is likely to break: the command will keep running and you can re-attach to the session to save the day. But as a dyed-in-the-wool bash user, I've kinda got used to being able to scroll up and down my &#8230; <a title=\"Copy tmux Scroll Buffer to a File\" class=\"read-more\" href=\"https:\/\/play.datalude.com\/blog\/2025\/10\/copy-tmux-scroll-buffer-to-a-file\/\" aria-label=\"Read more about Copy tmux Scroll Buffer to a File\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[4],"tags":[134],"class_list":["post-774","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/comments?post=774"}],"version-history":[{"count":1,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/774\/revisions"}],"predecessor-version":[{"id":775,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/774\/revisions\/775"}],"wp:attachment":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/media?parent=774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/categories?post=774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/tags?post=774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}