Installation
Ubuntu/Debian:
$ sudo apt install xclip
NixOS:
environment.systemPackages = with pkgs; [
xclip
];
The Magic Alias
Add this to your shell config:
alias clip="xclip -sel clip <"
Now you can copy any file’s contents directly to your clipboard:
$ clip myfile.txt
This grabs the contents of myfile.txt
and puts them in your system clipboard, ready for pasting anywhere.
I configure this in my NixOS setup by doing something like this:
{
programs.zsh = {
enable = true;
// ...
shellAliases ={
clip = "xclip -sel clip <";
};
};