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

  • Ever wanted to see how stuff changes over time? With a webcam this can be done quite easily. Set up cron/windows scheduled tasks  to go fetch a new image every minute/hour/day and compile the images to a video. I've made a really simple script for making a sliding window view of the past 24 hours that can be used on any image feed. Getting the images and making the video I wanted to use ffmpeg since it has a solid command line interface and it's available on most platforms. ffmpeg wants the image files in a sequential order, so we need to rename the images after adding the newest image. I'm not a bash expert (I usually solve stuff like this in Perl - when you have a hammer etc.), so it's probably other ways to make this work, but at least I think my code is quite easy to read and understand: # Make sure we are in the right directory and that it has an images directory cd /path/to/where/our/timelapse/stuff/will/be mkdir -p images # Delete files older than 1
  • Apart from being an excellent browser for web developers,  Google Chrome  is also a pretty awesome browser for everyone else. I've collected a few of the cool things you can do with  Chrome . 1. Incognito Window If you ever need to log in to the same service with two different accounts (say, if you're on your wife's computer and both want to check your gmail), open a 'New Incognito Window' (Shift+⌘+N/Ctrll+Shift+N). Cookies and history entries will not affect other windows. 2.  Undo a closed tab Yes, that's right, simply press Shift+⌘+T / Ctrl+Shift+T and the tab you just closed is opened again! AND - you can press it several times! 3. Pinned tabs Using the same web sites all the time? Wouldn't it be nice if they where always on the same tab so you could use keyboard shortcuts to access them  with ⌘+n / Ctrl+n (n is the tab number you wish to jump to)? Right click on the tab and select " Pin tab " and you have it! In addition, the ta
  • Disclaimer: This book was written by my colleague Marc Wandschneider .  I got the book as a free copy. TL;DR - This book is exactly what you need if you want to dive right into web development with Node.js. If you're already familiar with web technologies, it teaches you everything you need to know to start building end-to-end web applications using Node.js. One of my top annoyances are longwinded texts, trying to explain complex concepts. Especially when it comes to non-fictional books, and in particular books about programming. Show me a few lines of good, concise code, and I'll immediately understand what you're talking about. Try explaining it with just text, and I won't have the willpower (let alone the attention span) to read beyond the first couple of sentences. So, when I got a copy of Learning Node.js: A Hands-On Guide to Building Web Applications in JavaScript , I was really excited that it was only 250+ pages long. But my excitement quickly turned