I recently discovered xclip (amazing I never heard of that before!) and I must confess I find the need to add the -i and -o to “describe” the direction a little bit too verbose (at the very least, they could have done similarly to base64: pick one as the default, and have the user specify the other).

It’s also a bit clumsy (for me, at any rate) to have to think which “direction” this is going.

Be that as it may, as I also use MacOS a lot, and I find pbcopy and pbpaste easier to memorize and muscle memory takes over, so this is what I did in my aliases.sh (source‘d from my .zshrc):

# Ubuntu-specific aliases
if [[ ${OS} == 'Linux' ]]; then

    # A bunch of other aliases that only apply to Ubuntu
    ...

    # Make xclip behave like its MacOS counterpart
    alias pbcopy='xclip -i'
    alias pbpaste='xclip -o'
fi

And, yes I use the same .zshrc and aliases.sh on both machines (and it all sits in a -private- GitHub repository) with an additional init_local.sh (kept locally, and not under source control) for an extremely limited set of initializations that only apply to one machine.

This is how it can be used (obviously, the idea is that the clipboard content then may also be used in UI-based programs too):

└─( echo "test me" | pbcopy

└─( pbpaste                
test me

Leave a comment

Trending