Question

I have a copy in Screen's clipboard which contains the word Masi aften. I would like to replace it with Bond effectively such that I edit the clipboard directly in Screen's command-mode. I know that I could save the clipboard to /tmp and run the replacement there in Vim, but I want to learn Screen.

I run as I have my data in Screen's clipboard

Ctrl-A : sed s/Masi/Bond/ | [Screen's clipboard]       /// I do not know how to refer to Screen's clipboard by a command other that C-A ]

I get

unknown command sed

How can you run a command to Screen's clipboard in Screen's command mode?

Was it helpful?

Solution

I don't think screen has any way of running commands on the paste buffer.

One way to do it is to make a bind to save the paste buffer and open a new window in screen that runs a script to modify the buffer. Then make another bind to reload the modified buffer from disk and paste (this can be bound over the normal paste bind).

Add this to screenrc (changing paths):

bind -c screensed s eval "writebuf /pathtoscript/screensed.clipboard" "screen sh /pathtoscript/screensed.sh"
bind -c screensed p eval "readbuf /pathtoscript/screensed.clipboard" "paste ."
bind , command -c screensed

Make a shell script somewhere:

#!/usr/bin/env sh
echo "Enter sed script: "
read sedcommand
sed -i ${sedcommand} /pathtoscript/screensed.clipboard
echo "(Enter to return)"
read something

"ctrl-a , s" in screen will dump the clipboard and make a new window for the sed command to be entered. "ctrl-a , p" will read the clipboard and paste. The pause at the end of the script is to show any errors sed might give.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top