Python Forum
Cutting and Pasting from terminal programs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cutting and Pasting from terminal programs
#3
Hello,

Thanks for the reply! Yes, on a local machine terminal ctrl + shift + c or v is how to copy and paste (I'm using a Debian fork). My question above is about how to copy from the terminal session of a remote host and then be able to paste into a web browser on the local host. To do this, you need to get the copy buffer from the remote terminal pumped into the GNU copy buffer of the local computer.

I like to use kaa edit for Python editing, which is a terminal based program that works like a fancy version of nano or edit (or whatever the Windows basic terminal editor is called...been a long time).

Anyway, trawling the web, I patched together a workaround that works on Debian systems:

Requires xsel to be installed and your X11 to be forwarded.

1. First, forward your X11 display to the remote server: ssh -X user@remotehost
2. Start a screen session: screen -S mysession
3. Open kaa: kaa myscript.py
4. Enter screen's copy mode: ctrl-a [
5. Place cursor at desired mark and hit spacebar to set mark
6. Highlight the text you want, then hit spacebar to copy
7. Hit alt-z or otherwise close kaa
8. Use command: cat|xsel -bi or cat|xsel --clipboard
9. Use ctrl-a ] to paste into the STDIN buffer
10. Hit enter, then ctrl-d

Now what you copied is in your GNU copy buffer on the local computer -- Paste away! It seems like a lot of steps, but once you do it a couple of times, it's super straightforward.

-- Matt
Reply


Messages In This Thread
RE: Cutting and Pasting from terminal programs - by matt_the_hall - Jan-24-2021, 04:07 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020