Show HN: Cut, copy, and paste files in the terminal
github.com
github.com
For Linux, 'xclip -c' (copy) and 'xclip -p' (paste) respectively.
For MacOS, 'pbcopy' (copy) and 'pbpaste' (paste), respectively.
For Android, using Termux, 'termux-clipboard-set' (copy) and 'termux-clipboard-get' (paste) respectively. There are also keyboard mnemonics: Ctrl-Alt-C will copy, Ctrl-Alt-V will paste.
I believe there's also a feature on Windows via Cygwin, though it's been a couple of decades since I've had to use it.
Each of the above can read from stdin/stdout or file redirection.
E.g.:
cmd | xc # copy *from* command
xp | cmd # paste *to* command
xc <file # copy *from* file
xp >file # past *to* fileAnd, no criticism at creating your own implementation, but it's very, very far from the first CLI-clipboard integration.
If it makes you feel any better, I've coded up my own solutions to several problems, only to discover existing, and better, solutions myself. Multiple times.
MacOS: <https://duckduckgo.com/?t=ffab&q=command+line+clipboard+maco...>
First result, pbcopy/pbpaste: <https://osxdaily.com/2009/12/09/access-the-clipboard-from-th...>
Linux: <https://duckduckgo.com/?q=command+line+clipboard+linux&t=ffa...>
First result, several, including xclip: <https://www.baeldung.com/linux/clipboard>
Android: <https://duckduckgo.com/?q=command+line+clipboard+android&t=f...>
This does worse, though there are, again, several options listed.
If you think to substitute "Termux" for "Android", this becomes the first result:
<https://wiki.termux.com/wiki/Termux-clipboard-set>
Again: it's fine to produce tools, even redundant ones. But you'd be more credible with greater accuracy in your claims and statements.
What pbcopy/pbpaste, xclip, and the Termux commands offer is an alternative to pasting via mouse actions.
You can still interact with mouse-based controls. I'll typically do that, for example, when case-normalising titles using a shell utility I'd created.
Since 'xc' will overwrite the clipboard if invoked in the same pipeline, this command fails to deliver expected results:
xp | titlecase | xc
Instead, I can paste in some ALL CAPS TITLE, say: echo 'ALL CAPS TITLE' | titlecase | xc # Where 'ALL CAPS TITLE' has been pasted via mouse
Running 'xp' alone, we see the result: $ xp
All Caps Title
So, again, you seem not to understand either the problem space or the available tools.Well, it has! Not that that should stop you from building your own.