Some little gems on OSX you might want to know
filed in General on Feb.01, 2010
Here are some little things that might speed you up when working on a Mac.
1. View hidden files in Finder
In terminal type:
1 | defaults write com.apple.finder AppleShowAllFiles TRUE |
To hide them again:
1 | defaults write com.apple.finder AppleShowAllFiles FALSE |
2. Manage clipboard from command line
To copy the output of a parameter you can use pbcopy:
1 | pwd | pbcopy |
The result from pwd will be copied to the clipboard. You can seamlessly use pbpaste
3. Copy directory trees without overrideing
Imagine you’ve got 2 folders: v1 and v2 and you want to copy the contents of v1 inside v2 recursively (merging the contents). With a normal cp command you copy v1 to v2 and there’s a bin folder in both, the bin folder in the destiny will be completely replaced with the one found in v1.
If you were in Linux you would use cp -a, in Mac you can use:
1 | cp -pPR v1 v2 |
Where:
-p = preserve
-R = recursive
-P = no symbolic links are followed — can be added but this is the default
4. Adding some colors to ls
If you want to see some colors used when executing ls you can add the folowing lines to ~/.bash_profile:
1 2 3 4 | export TERM=xterm-color export LSCOLORS=fxhxcxdxbxegedabagacad alias ls='ls -la' export CLICOLOR=1 |
The second line changes the default annoying blue color applied to folders with a more readable red color.
5. VNC client
If you need to connect via vnc to any computer you don’t have to install a vnc client. Open Finder, press command+K and type vnc://host where host is the ip or domain you want to vnc to. A VNC client will automatically pop up.
If you want to allow incoming VNC connections to your MAC you can enable your VNC server open “System Preferences” > “Sharing” and check the “Screen Sharing” option.
6. Remote Login on X server via SSH
There are cases where you have to execute X applications remotely but the server doesn’t have a VNC server neither the possibility.
In these cases you can use:
1 2 | xhost host ssh -X -A userName@host |
Note that to be able to execute the commands above you need to have X11. The first line basically allows incoming connections from the server. The ssh command stablishes a connection against the host indicating that any application that nees an X server will be run in the local computer.
Once logged in you can try to execute any visual application. You’ll see that the application pops up locally.
7. Open any document with the default application
You might want to open a random file from the command line in the default desktop application
1 | open aFile.ext |
To open current directory in finder:
1 | open . |
8. Open a terminal in current Finder directory
Lots of times you navigate to a certain folder using Finder and then you want to open a Terminal in that folder. To accomplish that you can install openTerminalHere applescript http://www.entropy.ch/software/applescript/
9. You don’t like your dashboard? Disable it!
1 2 | defaults write com.apple.dashboard mcx-disabled -boolean NO killall Dock |
10. Show current full path in Finder
1 2 | defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES killall Finder |
Do you know any other must-know command or gem?

