As I grow more comfortable with Ubuntu over my Mac, I’m starting to figure out how to fill those little gaps in functionality that don’t exist the same way on both systems. As I figure these out, I’ll be sure to post what I find, in case anyone else is making this same transition.
I love the ability to open files from the command line and they are opened in the appropriate program. On the mac, you do something like:
open http://google.com
and it automatically knows how to open the file in the default browser. Or if you do an
open .
it will open Finder in the current directory. For someone who lives on the command line, this is just too good to pass up, and I needed to find the equivalent on Linux.
Turns out the that the equivalent is called xdg-open and is available by default on Ubuntu. So, a quick alias command and I could use open again.
alias open='xdg-open'
The other one I was missing was the ability to copy and paste directly from the command line. The most obvious one is when you’re setting up a new remote box and need to copy/paste your ssh key. Normally you do something like cat ~/.ssh/id_dsa.pub, copy it, remove all the line breaks, etc. and paste it into the proper place. However, on the Mac, you could do;
cat ~/.ssh/id_dsa.pub | pbcopy
and it would automatically be on your clipboard, ready for pasting into whatever. There is a command for pasting as well. I’ve used
pbpaste > /tmp/some_file
plenty of times to copy the contents of the clipboard into a file without having to open it up in a text editor first. It’s great.
After some quick digging, there is an alias for this as well and works great.
alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'
Magic!