Shell gems

I found a really good thread via +Patrick Aljord today called Give me that one command you wish you knew years ago on reddit.

It had a few really cool commands that I honestly didn't know about:


Ever been in a situation where you'd like to turn off your laptop, but you just started a long lasting process and forgot to use screen? disown to the rescue:
[1]+  Stopped
$> bg
$> disown
# Process still lives, although terminal is disconnected


How about those simple one-liners that somehow always turn out to
be so long that they really should be done as a script on file instead?
$> ls | perl -nle 'started-out-short-and-neat-but-now-long-and-complex-oneliner'
$> fc
# Opens your $EDITOR and pastes the last command used, ready to be edited and saved!

cd -

cd - is a small little gem that basically changes your current path to
you previous directory (see also pushd and popd):
$/very/long/path/to/somewhere > cd /another/very/long/path/to/somewhere
$/another/very/long/path/to/somewhere > cd -
$/very/long/path/to/somewhere >
You can also use it to copy something from your previous directory:
$/very/long/path/to/somewhere > cp `cd -`/file.txt .


This one speaks for it self:
$> units "100 kg" stones
    * 15.747304
    / 0.063502932

OSX Bonus

For OSX users I tend to find pbcopy and pbpaste really usefull for copying and pasting to the clipboard:
$> ls *.jpg | pbcopy
# Copy file-list to clipboard

I also discovered that my soon-to-be-collegaue +Adam Ohren made a cool tool
called pbfcopy that does the same as pbcopy only for files. Nice!

Popular posts from this blog

Automating webcam time lapse

Kratu - Decision Matrices on Steroids

Cool things to do with chrome