9

On tty2, how do I take a text screenshot of the command line?

1

3 Answers 3

13

Did you consider the screendump command?

4
  • 3
    "Just saying cat /dev/vcsN has a similar effect". Then why not just use cat /dev/vcsN? Commented Nov 24, 2018 at 16:45
  • 5
    Try it and see. Commented Nov 24, 2018 at 16:46
  • Nice. Is there a way to get it to do colour as well? (screendump reads from /dev/vcsa devices which does have colour information, but it seems to be stripped from the output.) Btw. I like to combine it with the watch command to see live output like watch -n0.1 screendump. Commented Nov 25, 2018 at 13:25
  • @WeijunZhou /dev/vcs devices don't contain information about the size of the screen, so cat /dev/vcsN only works if your terminal window has the same number of characters across as the VC you are capturing. Commented Nov 25, 2018 at 13:26
4

If you can use tmux or screen, they have the ability to save the scrollback buffer to a file.

Unlike screendump, which is Linux-only, tmux and screen are available for BSD-based OSes too (e.g. macOS, FreeBSD) and won't require special permissions.

2
  • Because of that, I marked this one as accepted. But @RudiC Don't take it personally. Your solution is still the simplest. Commented Nov 25, 2018 at 10:28
  • Those two add another layer; you need to login and then run screen, have another shell, and then can communicate with your CLI. Commented Nov 25, 2018 at 11:54
2

You can use script for this. It will record a typescript of the terminal session. By default, it will write to ./typescript. Of course, you need to do this in advance so it is not really a "screenshot".

$ script
Script started, file is typescript
$ ls asdf
ls: cannot access asdf: No such file or directory
$ exit
Script done, file is typescript

# Then check the recordings:

$ cat typescript
Script started on Thu 29 Nov 2018 02:52:04 PM CET

$ ls asdf
ls: cannot access asf: No such file or directory
$ exit

Script done on Thu 29 Nov 2018 02:52:09 PM CET

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.