Intro to Using EECS Workstations

Version 2.0
3.1 How to Customize the Shell [Back to Homepage]



WARNING: Please be absolutely sure you know what you are doing if you are modifying your startup files. Even small typos can lead to the whole program not working properly. If you are unsure about things, it is best to ask someone for help or just not alter those files at all.

I. The Basics

You can customize the behavior of the shell through adjusting certain settings. A good place to put these settings is in the startup file. These files contain settings and commands that are executed each time you start that particular shell, so you won't need to re-enter the customization settings each time you start a new terminal.

For example, for the csh shell, the startup file is .cshrc. I like to use the bash shell, so let's consider that shell as our example. Each shell has a different style for its scripting language, so these examples will apply to the bash shell.

By the way, I like using the bash shell because it has several nice features. There is tab completion, which means, if you type a few letters and then press Tab, bash will try to complete the command. There is also command history, which allows you to browse recently used commands by using the up key. Also, the Backspace key doesn't produce a weird ^H character on the screen as csh sometimes does.

To start bash, just type it in the shell:

cory% bash

The startup file corresponding to bash is .bashrc. Typically, startup files are located in your home directory. Thus, to edit it, you would do:

cory% emacs ~/.bashrc &

One good command to put in the .bashrc file is the alias command. It assigns an arbitrary letter combination the value of a command or a whole sequence of commands. This allows you to abbreviate and reduce typing.

For example, to replace typing "ls -Fal | more" with "all", you would include the following line in your file:

alias all="ls -Fal | more"

This syntax works for bash. For other shells, it is slightly different.

Any command you can type into the prompt normally, you can include in your startup script. And it will get executed at each startup. Some examples include:

who
quota -v $USER
cd ~/MyDocuments
echo "Howdy Richard!"

Lastly, in the bash shell, the pound sign (#) is used at the beginning of each commented line. Anything following the pound is ignored.


II. Sample

Here is my sample file, complete with comments. You can use it as an example or template.

Download Here!
bashrc.txt (3 k)
Save into your home directory, and rename to .bashrc

The file is a plain text file (as it should be). You can click on it to read it now or save it. But for it to take effect, you'll need to save it to your home directory. In addition, you'll need rename it to .bashrc. (I had to name it bashrc.txt just because Geocities can not host a file that starts with a dot.)

There are more advanced features of shell customization. This guide just introduces some basics to get you started.

©Copyright 2001, Richard Shiao. All rights reserved. Please send comments to: [email protected]
Hosted by www.Geocities.ws

1