Awesome Conferences

New to Mac OS X? Tips for Unix users

A friend of mine who is an old-time Unix/Linux user asked me for suggestions on how to get used to Mac OS X.

The first mistake that Unix users make when they come to OS X is that they try to use X Windows (X11) because it is what they are used to. My general advice: Don't use X windows. Switching between the two modes is more work for your hands. Stick with the non-X11 programs until you get used to them. Soon you'll find that things just "fit together" and you won't miss X11.

Terminal is really good (continued lines copy and paste correctly! resize and the text reformats perfectly!). I only use X windows when I absolutely have to. Oh, and if you do use X11 and find it to be buggy, install the third-party X replacement called XQuartz (sadly you'll have to re-install it after any security or other updates)

Now that I've convinced you to stick with the native apps, here's why:

  1. pbcopy <file

Stashes the contents of "file" into your paste buffer.

  1. pbpaste >file

Copies the paste buffer to stdout.

  1. pbpaste | sed -e 's/foo/bar/g' | pbcopy

Changes all occurances of "foo" to "bar" in the paste buffer.

  1. "open" emulates double-clicking on an icon.

    open file.txt

If you had double-clicked on file.txt, it would have bought it up in TextEdit, right? That's what happens with "open file.txt". If you want to force another application, use "-a":

open -a /Applications/Microsoft\ Office\ 2008/Microsoft\ file.txt

Wonder how to start an ".app" from Terminal? Double click it:

open /Applications/Microsoft\ Office\ 2008/Microsoft\

Want to find a directory via "cd"ing around on the Terminal, but once you get there you want to use the mouse?

cd /foo/bar/baz
open .

I use this so much I have an alias in my .bash_profile:

alias here="open ."

Now after "find"ing and searching and poking around, once I get to the right place I can type "here" and be productive with the mouse.

  1. Want to use a Unix command on a file you see on the desktop? Drag the icon onto the terminal.

type: od (space) -c (space)

Then drag an icon onto that Terminal. The entire path appears on the command line. If the path has spaces or other funny things the text will be perfectly quoted.

  1. Dislike the File Open dialog? Type "/" and it will prompt you to type the path you are seeking. Name completion works in that prompt. Rock on, File Dialog!

  2. Word processors, spread sheets, video players and other applications that work with a file put an icon of that file in the title bar. That isn't just to be pretty. The icon is useful. CMD-click on it to see the path to the file. Select an item in that path and that directory is opened on the Desktop.

That icon in the title bar is draggable too! Want to move the file to a different directory? You don't have to poke around looking for the source directory so you can drag it to the destination directory. Just drag the icon from the title bar to the destination directory. The app is aware of the change too. Lastly, drag the icon from the title bar into a Terminal window. It pastes the entire path to the file just like in tip 5.

  1. If you want to script the things that Disk Util does, use "hdiutil" and "diskutil". You can script ripping a DVD and burning it onto another one with "hdiutil create" then "diskutil eject" then "hdiutil burn".

  2. rsync for Mac OS has an "-E" option that copies all the weird Mac OS file attributes including resource forks. ("rsync -avPE src host:dest")

  3. "top" has stupid defaults. I always run "top -o cpu". In fact, put this in your profile:

    alias top='top -o cpu'

  4. For more interesting ideas, read the man pages for:

    screencapture mdutil say dscl dot_clean /usr/bin/util pbcopy pbpaste open diskutil hdiutil


P.S. others have recommended this list:

No TrackBacks

TrackBack URL:

3 Comments | Leave a comment

With Snow Leopard, they've fixed the XQuartz package so it installs in parallel with Apple's X11 (so you don't have to reinstall it after every security update).

The open command also has a -t flag to open a file with the editor you've set as default in LaunchServices (in case you prefer Emacs, Aquamacs, TextWrangler, or any of the other Mac text editors). If you've reset your default editor, but want to open a particular file with TextEdit, you can use the -e flag.

Also, TextEdit can open Word documents, and open them lots faster. It's really useful for when someone sends you a Word document where you need to do something with the content and you're not worried about their formatting. (You can also use TextEdit to export pretty clean HTML, and even clean up HTML coming from Microsoft apps.)

And, of course, if you miss GNU-specific features (e.g., the BSD find command doesn't quite do it for me), you can install a lot of other software through MacPorts.

Great tips, Claire! Thanks!

One of the little "tricks" I use the most is, say I'm in a finder window (i.e. double clicked a folder icon) and I want to open a terminal and go into that directory.

Simple, open your terminal, type "cd " and then drag the folder icon from the top of the finder window into the terminal window and let go of the mouse.

Viola! You have the path put into the terminal command line.

Leave a comment