On 30/09/26 at 00:52, Darac Marjal wrote:
And, if you don't want either, you could always ask your terminal to
copy the text to your clipboard on your behalf:
osc52() {
printf '\033]52;c;';
base64 -w0;
printf '\a';
}
That can work through tmux, through SSH and so on.
interesting, sorry for the late in the answer, of course to not annoying
you just with my dummies questions I asked to a LLM tool about what does
that function do.
So I discovered that "osc52()" stands for "Operating System Command 52"
and, to make this function accepts text passed as argument, I merged the
Greg's toclip() code with this result:
osc52() {
printf '\033]52;c;';
if (($#)); then
printf '%s' "$*" | base64 -w0;
else
base64 -w0;
fi
printf '\a';
}
Now it works in these test cases:
frank@itek:~$ osc52 some text
frank@itek:~$ cat b.txt | osc52
frank@itek:~$ osc52 <b.txt
finally another relevant thing is that osc52() also it works as
superuser, no need of privileged escalation in the code, you can use it
as it is also when you are "root" user.
Thank you for sharing that code,
--
Franco Martelli