How to set up you Unix Environment for OS X

From OS X Scientific Computing

(Difference between revisions)
Jump to: navigation, search
m
m (Find Apple's Terminal.app)
Line 6: Line 6:
<html><img src="http://sage.ucsc.edu/~wgscott/xtal/xtal-Images/findterminal.png" /></html>
<html><img src="http://sage.ucsc.edu/~wgscott/xtal/xtal-Images/findterminal.png" /></html>
-
A nice third-party alternative is [http://www.iterm2.com/#/section/homeiTerm | iTerm].  I use it.
+
A nice third-party alternative is [http://www.iterm2.com iTerm].  I use it.
-
 
+
==Open it==
==Open it==

Revision as of 19:45, 14 March 2012

Contents

Find Apple's Terminal.app

It resides in /Applications/Utilities:

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

Open it

When you open Terminal.app, 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).

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/init.sh

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 Terminal.app and xterm, but not Terminal.app'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 

or

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


Personal tools