39

I've had an interesting terminal session in byobu, and I'd like to save the terminal output (commands and all) to a file - how can I do that?

According to the byobu man page:

Ctrl-a ~ - Save the current window's scrollback buffer

This may indeed be doing something, but I've found no indication of where and under what name it might be saved.

drevicko
  • 4,523

9 Answers9

47

An old question still not workably answered for earlier byobu versions, and I hit the need again.

This time I found a workable solution. From man byobu:

SCROLLBACK, COPY, PASTE MODES

Each window in Byobu has up to 10,000 lines of scrollback history, which you can enter and navigate using the alt-pgup and alt-pgdn keys. Exit this scrollback mode by hitting enter. You can also easily copy and paste text from scrollback mode. To do so, enter scrollback using alt-pgup or alt-pgdn, press the spacebar to start highlighting text, use up/down/left/right/pgup/pgdn to select the text, and press enter to copy the text. You can then paste the text using alt-insert or ctrl- a-].

  1. I hit F7 to enter scrollback mode,
  2. Space to start selecting,
  3. gg to scroll to the top of the buffer (thanks @GeorgeMarian)
    • If that doesn't work, try this: either with lots of Page up or : followed by the largest line number (indicated top right) and Page up to get to the top of that page,
  4. Enter to copy (to byobu's clipboard, not a terminal/system one),
  5. then cat > my-byobu-dump.txt in the terminal,
  6. Alt+Insert or ctrl+A,] to paste (again, from byobu's clipboard)
  7. Ctrl+D to close the file.
drevicko
  • 4,523
32

Or, you can simply use Byobu's hotkey for this:

  • Shift-F7

That will take your history and put it into $BYOBU_RUN_DIR/printscreen.

Pablo Bianchi
  • 17,371
5

If you're used not to use the F-keys then this might work for you:

  • Ctrl+a, [: enter the scrollback mode
  • Space enter the copy mode (optional)
  • Enter exit the scrollback or copy mode
  • Ctrl+a, ]: paste what was copied

Where Ctrl+a is your tmux (default Byobu backend) prefix/escape sequence.

Pablo Bianchi
  • 17,371
3

Shift + F7 only works as expected if you have the EDITOR environment variable set to an editor within byobu. For some reason, in some cases (e.g. for me when connecting through SSH to another computer), setting this variable in ~/.profile is not enough. One place to set it so that byobu always reads it is in ~/.bashrc. Copy something like the following to your ~/.bashrc:

# Although this is set in ~/.profile, it is set here as well so that in a 
# remote byobu session, Shift+F7 copies the output to a Vim buffer. See:
# https://askubuntu.com/questions/382750/how-to-save-scrollback-history-in-byobu
export EDITOR='vim'
1

If you need to save the history use Shift + F7 shorcut. Like @dustin-kirkland says.

If you prefer to scroll up and down in your terminal, It depends if you use tmux or screen. Examples:

  1. Screeen:

    • CTRL + a: If you use [ then, you enter in scroll mode like @ikar-pohorský says.
  2. Tmux:

    • ALT + PageUp: you scroll up.
    • ALT + PageDown: you scroll down.

Byobu F1 help

mrroot5
  • 559
1

Ctrl+a, ? shows me that capture-pane and save-buffer are the key commands to save scrollback.

bind-key    -T root   S-F7             capture-pane -S -32768 ; save-buffer /dev/shm/byobu-asari-JG2wDS8x/printscreen ; delete-buffer ; new-window -n PRINTSCREEN " /dev/shm/byobu-asari-JG2wDS8x/printscreen"

When Shift+F7 doesn't work for you (e.g. when your terminal software consumes F-key events), try just as help says: Ctrl+a, :, capture-pane -S -32768 ; save-buffer /path/to/printscreen and Enter.

asari
  • 111
1

Use Ctrl+A+~ to copy the scrollback buffer to the byobu clipboard.

Paste the text into an editor using Alt+insert or Ctrl+A+].

(Adjust Ctrl+A if you've changed your escape key.)

snoop
  • 4,110
  • 9
  • 41
  • 58
0

Ctrl+A+] will work if you type from 1 to 20 times or more with abracodabra. But the only one command will work without headache to paste text from buffer to terminal or file is Alt+Ins. Byobu is GPLv3 software, authored and maintained by Dustin Kirkland.

Pablo Bianchi
  • 17,371
bemonolit
  • 935
-1

Select the text you wish to save, then press Control + Shift + C Next, open your favorite text editor. Then paste the content here using Control + V . Finally save the file in the desired location.

TERMINAL TIP OF THE DAY: When trying to copy something in terminal do it as usual expect use Control + Shift + C instead of Control +C, and paste as usual. For pasting something that is on the clipboard into the terminal use Control + Shift + V.

cubecubed
  • 694
  • 7
  • 25