How to set up you Unix Environment for OS X

From OS X Scientific Computing

Jump to: navigation, search


Find Apple's

It resides in /Applications/Utilities:

A nice third-party alternative is iTerm. I use it.

Open it

When you open, you should see something akin to this:

It starts up in the "bash" shell by default. Mac OS X unix (Darwin) offers several shells, including bash (the default), tcsh, zsh, and ksh. Many crystallographers prefer tcsh, and I prefer zsh. Both tcsh and zsh are more user-friendly than bash (and ksh).

Initialize your environment

If you want to use programs installed with fink, your shell needs to be told to look in /sw/bin and have some additional environment variables set.

The way to do this is to issue the command

source /sw/bin/

which will do everything you need if you are running bash or zsh.

If you are running tcsh, you need instead to issue the command

source /sw/bin/init.csh

because the (t)csh syntax is incompatible with everything else.

It gets tiresome to issue that command every time you open a terminal window, so you will probably want to create a shell startup file, and put the command inside of it.

Customizing your bash (or other shell) environment

When you open a Terminal or terminal-like application, it will invoke your default user shell. As the shell starts up, it looks for various system and user-created startup files that govern customizable settings for environment variables, the prompt, aliases, functions and so forth. What files are read depends upon which shell is invoked and which files are present. The user will need to create files in his or her home directory and include in them various commands in the appropriate syntax. Here is a listing of user shells along with what files will be read on startup. In several cases I have provided links to sample startup files (i.e., .bashrc, .bash_profile, .zshrc, .cshrc) to help get you started. These all include customizations for iTerm title bar and tab labels (these will also work for the title bar on and xterm, but not's tabs). The files are commented to help you understand and change the customizable parts.

Shell User files Comments
bash .bash_profile or .bashrc .bashrc for non-login and .bash_profile for login shells
tcsh .login and .cshrc .cshrc is always read
zsh .zlogin and .zshrc and .zshenv .zshenv is always read; .zshrc almost always read

Changing your Shell

If you want to change to being a tcsh user, or to become a zsh user, just type one of the following commands:

chsh -s /bin/tcsh 


chsh -s /bin/zsh 

You will be prompted for your password. The change sticks. Issue the command

chsh -s /bin/bash 

to undo it.

I personally recommend using zsh, as it has more power than bash and is more user-friendly than tcsh. (bash copies many of its more innovative features). If you are interested, please see my page entitled Why zsh Should Be the Default Shell on OS X

This has lots of crystallography-specific customizations:


Personal tools