1

My intention is to copy many pages of my terminal output to a file for logging purpose. The trick to copy screen content does not work well with me. It requires too many keys to remember, and even if I remember it, it is still slower than Shift+F7 to capture the whole thing.

However, Shift+F7 opens a new window tab name "PRINTSCREEN*" using my environment $EDITOR, and if I choose to save it (using vim or emacs), it will save to something like /tmp/shm/byobu-username-RanDomNameDir/.

I will have to navigate to my $PWD to save the file. The path is most of the time very deep and long. Is there a way I can change so that the temporary buffer of byobu's PRINTSCREEN default to $PWD?

Update:

Why not just use redirection?

Many suggested this. The answer is, I know about redirection. But this is not the case to use it. I do interactive with the terminal to explore various direction before script the work and redirect output to file "properly". My question is about tweaking configuration of byobu's Shift+F7 command. The sole purpose of it is to serve the use cases where screen redirection did not happen. So no need to talk about screen redirection please.

2 Answers2

1

Use Linux embedded script utility. For example, to capture everything from terminal to file capture.log in the current directory (get it with pwd), do:

script capture.log

To stop capturing just type exit or press CTRL+D. More information on script and its options:

man script

Remark. Script utility output files contain raw control characters, thus to read it use less with -r and -R options, i.e.

less -rR capture.log

To clean output files from raw control characters use the command:

cat capture.log | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > capture-clean.log

The last command removes raw control chars from capture.log file and creates plain text file capture-clean.log.

Additionally read How to clean up output of linux 'script' command.

Bob
  • 2,563
0

After some testing, I decided that it's best to fix from the root: not byobu, but tmux. Some nice developer at tmux community made a patch. And things works perfectly now: https://github.com/tmux/tmux/issues/1400