Some little gems on OSX you might want to know

Here are some little things that might speed you up when working on a Mac.

1. View hidden files in Finder

In terminal type:

defaults write com.apple.finder AppleShowAllFiles TRUE

To hide them again:

defaults write com.apple.finder AppleShowAllFiles FALSE

2. Manage clipboard from command line

To copy the output of a parameter you can use pbcopy:

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:

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:

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:

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

open aFile.ext

To open current directory in finder:

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!

defaults write com.apple.dashboard mcx-disabled -boolean NO
killall Dock

10. Show current full path in Finder

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
killall Finder

Do you know any other must-know command or gem?

5 Comments to “Some little gems on OSX you might want to know”

  1. Dta 1 February 2010 at 11:12 pm #

    Great! Nice tips Xavi!

    Thanks

  2. Dta 2 February 2010 at 10:31 am #

    If you are bored with your old hostname, you can change it:

    sudo scutil –set HostName servername.forexample.com

    Enjoy!

  3. Luis Adrián 3 February 2010 at 10:40 am #

    Excellent work Xavi,

    On the subject of ssh added. When you connect to the server probably need to edit any file, that’s where come in vim, nano, or emacs. But perhaps this is very geeky.

    Greetings!!

  4. [...] occurred to me that I would have any use of these tips until I had read rialvalue’s “Some little gems on OSX you might want to know”. For example, it’s sometimes useful to view hidden files from the Finder/Explorer window [...]

  5. Alberto Alcaraz 2 March 2010 at 8:18 pm #

    For #3 I use ditto (“ditto v1 v2″) to accomplish the same.

    For #8 I type “cd ” and then drag the folder to the terminal.

    Great post! :P


Leave a Reply