vote up 16 vote down star
29

One tip or trick per answer.

My favorite is

open .

Opens the folder you're currently browsing in Finder.

Yes, we're looking for Mac OS X specific.

flag
2  
Should be community wiki. – jtimberman Oct 7 at 22:26
1  
This should be a community wiki, since there is no clear answer. – Giffyguy Oct 7 at 22:26
1  
Here is one of the generic terminal "most useful" type of question. Many of these will work under os x and some wont. superuser.com/questions/18730/… – Troggy Oct 7 at 22:32
1  
There is a similar thread on Server Fault as well: serverfault.com/questions/7346/… – Chealion Oct 7 at 23:07
show 1 more comment

19 Answers

vote up 13 vote down check

pbcopy and pbpaste:

# Copy output of command to clipboard
grep 'search term' largeFile.txt | pbcopy

# Abuse clipboard contents
pbpaste | sed 's/ /%20/g'
link|flag
show 1 more comment
vote up 11 vote down

It's not built in but this is the most effective way to get my wife to stop using my laptop to read celebrity news for hours after 4-5 requests to get my macbook back:

echo 'The system is overheating and needs to go to sleep now.' | \
growlnotify -a 'Activity Monitor' 'OVERHEATED'; \
sleep 1; \
say 'Overheated system.'

Since it's almost always around 70c it's believable.

Growl showing an 'Overheated' warning.

link|flag
3  
+1 Hilarious. Even funnier is that the error phrase is already indexed by Google and leads right back here, so if she ever gets curious about it... – hyperslug Oct 9 at 15:28
1  
It's an add-on: growl.info/documentation/growlnotify.php – EmmEff Oct 11 at 13:30
show 2 more comments
vote up 10 vote down

The say command invokes the system text-to-speech capabilities.

say "Hello there."
link|flag
2  
I use it to freak people out. SSH into my neighbors mac and say random things. – Josh K Oct 8 at 2:00
4  
Can be useful if you're locked outside of your apartment :) xkcd.com/530 – Philippe Mongeau Oct 8 at 3:02
show 1 more comment
vote up 9 vote down

opensnoop is my new favorite utility. It uses DTrace to show you all of the files that are being accessed on your system, you need to execute it with superuser privileges

sudo opensnoop

You can also watch what a particular process opens by passing in the PID:

sudo opensnoop -p PID

Or watch a particular file to see who's opening it

sudo opensnoop -f /etc/passwd
link|flag
show 1 more comment
vote up 5 vote down

(Assuming we're looking for Mac OS X specific tricks.)

I've got an alias to launch quicklook on a file from the command line:

$ type -a ql
ql is aliased to `qlmanage -p 2>/dev/null'
$ ql photo.jpg
Testing Quick Look preview with files:
    photo.jpg

Hit CtrlC to kill it and return to the prompt.

link|flag
show 1 more comment
vote up 4 vote down
$ emacs -batch -l dunnet

Dead end
You are at a dead end of a dirt road.  The road goes to the east.
In the distance you can see that it will eventually fork off.  The
trees here are very tall royal palms, and they are spaced equidistant
from each other.
There is a shovel here.
>
link|flag
show 3 more comments
vote up 3 vote down

history shows a list of the recent commands you've run — something like 500 or 600 commands. I frequently use history | grep something to find a command i've used recently.

link|flag
4  
That's a bash builtin, not OS X specific. – Tadeusz A. Kadłubowski Oct 8 at 6:00
show 2 more comments
vote up 3 vote down

Although I can get around in vi, I use TextMate as my command line editor. You can also pipe things to it. For example ls|mate opens up TextMate with the current directly listing open in a text window.

link|flag
show 1 more comment
vote up 2 vote down

With hdiutil you can easilly mount a disk image:

hdiutil mount ~/Desktop/lastest_webkit.dmg

Dismounting takes a bit more work:

hdiutil detach `df | grep WebKit | perl -pe 's@^/dev/([a-zA-Z0-9]+).*@$1@'`
link|flag
2  
Just do "hdiutil detach /Volumes/<mountpoint>" – churnd Oct 11 at 14:09
vote up 1 vote down

diskutil is a very powerful command-line tool for working with disks and disk images. It's gotten me out of some binds. It's not too hard to use.

link|flag
vote up 1 vote down

Quickly check what is eating all your memory:

top -o vsize

And for your CPU

top -o cpu

Q to quit

link|flag
show 1 more comment
vote up 1 vote down
!!

Runs the last command again. Great for tracking changes.

link|flag
vote up 1 vote down

the most interesting pschotherapist you will ever talk to:

  • Run emacs
  • Press shift-esc, then x
  • type doctor and press enter
  • have fun :D
link|flag
vote up 1 vote down
cd -

Will restore the previous directory you were in. Very handy if you accidentally type cd and flip to home.

link|flag
vote up 0 vote down

I've recently been using net rpc shutdown --server=<servername> --username=<username> to shutdown my windows boxes.

link|flag
show 1 more comment
vote up 0 vote down

http://github.com/joelthelion/autojump - "cd" that learns.

link|flag
vote up 0 vote down

mdfind to use spotlight from the command line - really really really handy! Finds things in every directory as well, so it's more useful when looking for files that are part of the system.

mdfind -live updates in real time, which again is incredibly handy.

link|flag
vote up 0 vote down

textutil is a very handy tool that can cross convert text between HTML, RTF(D), Word (including XML), OpenOffice.org Writer, and the webarchive format.

I use it, notably, in a service that converts the selected text to HTML, uploads it to a server then imports it into Instapaper.

link|flag
vote up 0 vote down

cd - jumps back to the last directory you were in.

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.