Skip to content

Setting up your environment

iliano edited this page Sep 3, 2020 · 14 revisions

You should have already seen how to add the C0 compiler cc0 and the C0 interpreter coin to your PATH so that when you type cc0 or coin at the command line. You've also seen how to edit a file in some editor of your choice, either Emacs or Vim. For you to be an effective 122 student, it is important for your PATH to be set up automatically when you log in, and it is also important for your editor to know some things about C0.

This task has two steps, and should be done on an Andrew machine. First you'll set up your PATH, and second you'll set up your editor(s). You should either be using a cluster computer or connected to unix.andrew.cmu.edu with SSH.

Setting up your PATH

This step will be done for you if you're in the GPI course and follow the instructions here. You can skip to setting up your editor.

For this step, you need to first type the following command. The next steps you follow depend on what gets printed when you run this command:

% echo $SHELL

Follow the appropriate instructions below. After you follow those instructions, log out and log back in: cc0 and coin should now be recognized commands.

...if you see /bin/csh when you run echo $SHELL

Use an editor (emacs of vim) to open the file $HOME/.cshrc. If the file doesn't exist yet, create it so that it contains just the following line; if the file already exists then add the following line at the very end:

setenv PATH ${PATH}:/afs/andrew/course/15/122/bin

...if you see /bin/bash when you run echo $SHELL

Use an editor (emacs or vim) to open the file $HOME/.bashrc. If the file doesn't exist yet, create it so that it contains just the following line; if the file already exists then add the following line at the very end:

export PATH=$PATH:/afs/andrew/course/15/122/bin

Then, open the file $HOME/.bash_login. Add the following line:

source ~/.bashrc

Setting up your editor

There are several editors that are popular with 122 students. The Emacs and Vim instructions assume you are using a cluster Unix machine or SSHing into unix.andrew.cmu.edu.

Emacs

To set up C0 for Emacs, run the following command:

% /afs/andrew.cmu.edu/course/15/122/bin/setup_config/emacs/setup.sh

Then, just quit and relaunch emacs, and syntax highlighting and indentation should work.

Vim

To set up C0 for Vim, run the following command:

% /afs/andrew.cmu.edu/course/15/122/bin/setup_config/vim/setup.sh

Then, just quit and relaunch vim, and syntax highlighting and indentation should work.