On tty2, how do I take a text screenshot of the command line?
Asked
Active
Viewed 849 times
9
-
1Related: [Where is terminal output stored?](https://unix.stackexchange.com/q/472328) – sondra.kinsey Nov 30 '18 at 19:51
3 Answers
13
Did you consider the screendump command?
RudiC
- 8,889
- 2
- 10
- 22
-
3"Just saying `cat /dev/vcsN ` has a *similar* effect". Then why not just use `cat /dev/vcsN`? – Weijun Zhou Nov 24 '18 at 16:45
-
5
-
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`. – kasperd Nov 25 '18 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. – kasperd Nov 25 '18 at 13:26
4
If you can use tmux or screen, they have the ability to save the scrollback buffer to a file.
- Write all tmux scrollback to a file
- Copying GNU screen scrollback buffer to file (extended hardcopy)?
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.
jamesdlin
- 838
- 6
- 19
-
Because of that, I marked this one as accepted. But @RudiC Don't take it personally. Your solution is still the simplest. – neverMind9 Nov 25 '18 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. – RudiC Nov 25 '18 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
Rolf
- 892
- 1
- 7
- 10