Score:1

Escape code sequence for copying file content

cn flag

I found from here that you can use ANSCI Escape sequence to copy from a remote ssh session like so,

printf "\033]52;c;$(printf "%s" "blabla" | base64)\a"

I have tried issuing command,

$ (file=README.md; printf "\033]52;c;$(base64 $file)\a")

But I am able to print only the first few characters (~57 characters). Is there a way to copy the whole content of a file with the Escape sequence?

cocomac avatar
cn flag
Is there a reason you are not just [using `scp` to copy the files](https://askubuntu.com/a/646448)?
cn flag
It would be more convenient since I am usually in an interactive session.
bac0n avatar
cn flag
you are missing the %s specifier on the first `printf`
cocomac avatar
cn flag
Also see [this answer](https://askubuntu.com/a/13586/1438484). It looks like it does what you want, and looks far easier @bac0n Mind posting that like an answer? It looks like it would be a good one!
Score:2
cn flag

If you want the output printed to the clipboard you may use xclip

xclip -sel -p -i < <( \
 printf %s%s%s '\033]52;c;' "$(printf %s blabla | base64)" '\a' \
)
cn flag
The downside is that the ssh server does not have X Window running.
bac0n avatar
cn flag
@phoxd but your client does?
cn flag
Well, I am trying copy from a remote server. No point to run on my local machine.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.