As a freelance software developer I am constantly flipping between multiple operating systems and often get terminal commands confused. Probably one of the most common commands is
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 its syntax is a little too verbose and I prefer to use OS X
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
Script for pbcopy on ubuntu
I have created a quick script to help automate the configuration of pbcopy on ubuntu.
Please bear in mind, that due to the fact the script will be installing new software it will require elevated permissions to run. Typically I execute the script
For further information on How to execute a BASH script
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.
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.
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Latest posts by Gary Woodfine (see all)
- The Builder Pattern .net core - May 1, 2019
- Book Review: The Lean Startup - April 28, 2019
- Using Serverless Framework Environment Variables .net core Lambda - April 25, 2019