4

I'm using GNU screen and I want to save input from stdin into a register to slowpaste it later. I tried a workaround with a temp file (which I can read into a register with readreg afterwards) and to use cat:

:eval "exec | sh -c 'cat >/tmp/screentempfile'"

However, if I press CTRLD to send EOF to cat, it doesn't arrive.

finefoot
  • 2,940
  • 2
  • 21
  • 41

2 Answers2

3

That should rather be:

:exec ... sh -c 'cat > ~/.screen-paste'

You need stdin of cat to be coming from screen, hence the first .. The command shouldn't output anything, so the two other fds don't matter much, though it makes sense for them to go to screen as well, hence the two other .s.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
3

For completeness, this is a working command to read from stdin and save the input into a register:

:exec ... sh -c 'cat >"$HOME/.screen-stdin.tmp" && screen -S "$STY" -X readreg p "$HOME/.screen-stdin.tmp"'
finefoot
  • 2,940
  • 2
  • 21
  • 41