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:
pbcopy <file
Stashes the contents of "file" into your paste buffer.
pbpaste >file
Copies the paste buffer to stdout.
pbpaste | sed -e 's/foo/bar/g' | pbcopy
Changes all occurances of "foo" to "bar" in the paste buffer.
"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\ Word.app file.txt
Wonder how to start an ".app" from Terminal? Double click it:
open /Applications/Microsoft\ Office\ 2008/Microsoft\ Word.app
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.
- 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.
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!
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.
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
".
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
")
"top
" has stupid defaults. I always run "top -o cpu
". In fact, put this in your profile:
alias top='top -o cpu'
For more interesting ideas, read the man pages for:
screencapture
mdutil
say
dscl
dot_clean
/usr/bin/util
pbcopy
pbpaste
open
diskutil
hdiutil
Enjoy!
P.S. others have recommended this list: http://superuser.com/questions/52483/terminal-tips-and-tricks-for-mac-os-x