Another thing you can do is use screen. It creates a virtual terminal that can be detached from any tty/pty and reattached to another terminal.
So, for your use-case, it would be start the screen session on the console:
~ $ screen -L -S TestTerm
And, to clarify, "-L" turns on logging, which creates a logfile in the directory you started screen from, and "-S" gives the screen session a name that can help you discern which session is which when you list all screen sessions with "-ls".
Now, if you have to run the application from the console, then run the application, and as it is running, hit "(Ctrl+A)+(Ctrl+D)" to detach from the screen session. Then go into your desktop, open a terminal and run:
~ $ screen -ls
There is a screen on:
10296.TestTerm (Detached)
1 Socket in /tmp/screen/S-ChennyStar.
Now, you have the PID and name of your screen session, so reattach it to your xterm:
~ $ screen -d -r 10296.TestTerm
And, to clarify, "-d" tells screen to detach the session if it is still attached elsewhere, and "-r" tells screen to reattach the session to your current terminal.
Depending on the amount of output you want to copy, the output may have gone outside of the initial terminal buffer when you reattach. However, if it is that much output, the logfile will contain all of the output for you, as well.
Hope that helps.
pbcopy
andpbpaste
out of the box. There are some good answers here.xsel
orxclip
, see user253751's answer below, I don't know if they are the same as macOS's tools.