ubuntu - tips & tricks





flipping between multiple operating systems you are bound to get commands confused. For me one of those commands is pbcopy.

pbcopy on a mac enables you to copy the standard input from terminal window to your clipboard enabling you to paste it to other applications

You can replicate pbcopy on ubuntu by utilising a similar tool called xclip which does exactly the same.  However it’s syntax is a little too verbose and I prefer to use OS X pbcopy command.

Fortunately due to the fact that OS X and Linux *nix based we can make use of the The alias Command to replicate the pbcopy functionality in ubuntu.

how to configure pbcopy on ubuntu

If you haven’t previously installed xclip simply run the following command in your terminal window:

Edit your BASH settings file using your favourite text editor.  I’ll be using nano, but feel free to use Gedit or Vim etc.

Then create an alias for pbcopy and pbpaste:

Close and save the file then just refresh your bash to import your new settings




how to use pbcopy on ubuntu

After you have finished the configuration steps above you can simply use pbcopy on your ubuntu machine in much the same way you’ll utilize it on the mac.

This will copy your ssh public key and you can test if this works by pasting it into a Gedit text file.
This functionality also comes in very handy in situations when you need to copy the contents of your php info. For instance, when you need to configure xdebug to enable debugging for PHP.

You could use xclip to copy the contents

Or if you have taken the time to configure the short cut above you can make the command a lot easier to remember by removing some of the verbosity.

Summary

This is an example of how flexible, adaptable and customizable the Linux Operating system is. Simply utilising the The alias Command you’re easily able to replicate functionality found on the MacOSX directly on your Linux system.

This provides you with the capability to customise your system to how you prefer to work with it. Taking time to learn and understand the Aliases in Linux will help you to tailor your system and decrease the amount of typing you need to do.




Gary Woodfine

Founder & CTO of threenine.co.uk. Experienced full stack software developer well versed in delivering web & mobile applications utilizing cloud architectures. Areas of specialty include cross platform development in .net , PHP, JavaScript.

π