# How do you save a compiler message and copy it?



## neilms (Oct 7, 2013)

I am using emacs to edit source files and clang++ to compile them. When I test a program it sometimes does not compile the first time and the error messages are displayed on the console. I can use scroll lock to view lengthy error reports, but I sometimes need to copy the exact errors and paste them into my email / newsgroup client program when I ask for help.

If I were using x windows, it would be to simply select, copy and paste what I wanted. But I am using only the console and need to know how to do this in a console only environment. So suppose I compile a simple program at the plain command prompt (not in emacs) and get a lot of errors. How can I copy the exact output to paste it into a console newsreader like alpine or emacs?


----------



## wblock@ (Oct 7, 2013)

moused(8) lets the mouse cut and paste on the console.  With a USB mouse, moused(8) is started automatically.  For PS/2 mice, it must be run separately, usually with moused_enable="YES" in /etc/rc.conf.

There are other ways to capture things, like output redirection: `make whatever > /tmp/whatever.log`.  More powerful versions vary, depending on the shell.

Also, there is script(1).  Run it like `script /tmp/log.txt` to get a new session.  Everything from that session is captured in that file.  _Everything_, including control codes.


----------



## oops (Oct 8, 2013)

In tmux you can try copy mode: *C-b [* (mode), *C-r* or *C-s* (search), *C-@* or *C-SPC* (select), *C-w* or *M-w* (copy), *C-b ]* (paste). screen has similar mode but with vi-like keybindings. Unlike copying from xterm or via moused this method preserves formatting (except tabs) by undoing line-wrapping damage made by the underlying terminal.

Or use `vidcontrol -HP </dev/ttyv0` and trim unrelated parts in your editor.


----------

