Archive for the ‘Uncategorized’ Category

Five Cool OS X Terminal Tricks

Sunday, March 7th, 2010

Photo courtesy of Mads Sabroe

We all love Unix shell. I can’t remember when was the last time I had my Mac running without an open Terminal window. Here are couple of tricks you can do with it.

1. “cd -”
After finding this in all of its simplicity I asked many of Linux & OS X hardcore users and none of them knew this existed. “cd -” sends you back to the last directory you where in:

macbookpro:/ tuomas$cd usr/bin/
macbookpro:bin tuomas$ cd -
/
macbookpro:/ tuomas$ cd -
/usr/bin

2. “mkdir -p”
With mkdir you can make a directory, but adding the “-p” argument can make multiple directories in case those do not exist before. For example:

mkdir -p /home/bill/documents/books/computer

3. Update Twitter from shell with cURL

curl -u username:password -d status="Your tweet" http://twitter.com/statuses/update.xml

4. Speak a text file to spoken .aiff file

cat foo.txt |say -o foo

Now try this with Apache log;)

5. “history”
History shows you list of commands you have ran before like this:

526  cat blog-google-api.txt |say -o foo.mp3
527  open .
528  ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
529  history

If you want to run something from your history you can just: !527 and it will run command #527 from the history. In this case: “open .”