Sample Header Ad - 728x90

How do I copy a file to the clipboard with the terminal?

3 votes
3 answers
6524 views
I'm aware of how to copy the **contents** of file:
xsel -b < myfile.txt
But this is **not** what I want. I would like something like this:
./file2clip.sh myfile.txt
Which would copy myfile.txt to the clipboard so then I could ctrl + v (paste) or right click and paste **the file** anywhere (on the desktop, in the file explorer, etc.). How can I copy a file/files to the clipboard so that I can paste it with ctrl + v anywhere in the gui? Windows equivalent: (powershell)
Set-Clipboard -Path myfile.txt
Macos equivalent: (applescript)
#!/usr/bin/osascript
on run args
    set the clipboard to POSIX file (first item of args)
end
./file2clip.applescript myfile.txt
Asked by lordcommander (139 rep)
May 22, 2021, 01:00 PM
Last activity: Jun 24, 2024, 11:02 PM