Notice! This document is currently in Archived status.
The content of this document may be incorrect or outdated.

Print this article Edit this article

C Shell:How can I customize my Unix Session

Purdue Engineering Computer Network
Your home directory may include hidden files called .login and .cshrc if you are using the C shell. These files are the keys to customizing your account, since they contain commands that are automatically executed whenever you log in. The search path provided when you log in (before any commands in your .profile, .cshrc or .login are executed) will include /usr/local/bin and /usr/opt/bin, /usr/bin, /usr/site/<sitename>/bin and . ("." = working directory). So you do NOT need to put these directories in your path.

Dot File .cshrc

To save this file to your HOME directory via your WWW browser, go to the document and via your browser select Save As. Then save this document in the format of "Text" and then specify your HOME directory path (e.g., /home/dynamo/b/login) and name it .cshrc.

Dot File .login

To save this file to your HOME directory via your WWW browser, go to the document and via your browser select Save As. Then save this document in the format of "Text" and then specify your HOME directory path ((e.g., /home/dynamo/b/login) and name it .login.

How to Edit Your Dot Files To Customize Your Environment

The Search Path

The path variable is a shell variable that tells the shell where to look for commands. In the example .cshrc file, the path variable is set to

( $path  ~/bin )

This tells the shell to look first in $path, then the bin directory, (your own private directory of programs) and so on until the file has been found or all the directories have been looked at.

To append the above example: you can add directories to your path. It would look like:

set path = ( $path  ~/bin /directory/you/want/to/add )
Depending on which host you log in on, you will automatically receive the path /usr/site/<sitename>/bin. So if you log in on an ME host, you will automatically recieve /usr/site/me/bin. But if you want to append your path to always include a certain site, you can use the following syntax:
set path = ( $path ~/bin /usr/site/me/bin )

You may also want to add /usr/unsup/bin, in which case the following syntax is recommended:

set path = ( $path ~/bin /usr/unsup/bin )

The Structure of the .cshrc File:

set path = ( $path ~/bin /usr/unsup/bin )

You do not need the additional space that is inserted after the first parenthesis and before the last parenthesis of $path. Many people do put in this extra space because it makes it easier to read. If you have many directories, you need to insert a BACKSLASH ( \ ) and then continue to the next line. INSERT A SPACE before the backslash. And most users indent the second line (because it is easier to read), but it will still work if you don't indent it.

Example of long $path:

set path = ( ~/bin $path  /usr/unsup/bin /usr/site/me/bin /usr/local/X11R5/bin \

/usr/ucb )

Customizing Your Manual Page Path

setenv 	MANPATH	  $MANPATH:/usr/local/X11R5/man:/usr/unsup/man

You may also want to add additional manpages. The /usr/man, /usr/local/man, /usr/opt/man and /usr/site/<sitename>/man are automatically looked up. If you do add additional manpages to your $MANPATH, separate the directories by colons ( : ).

You must have at least ONE space between the setenv, MANPATH and $MANPATH:/usr/local/X11R5/man:/usr/unsup/man. Many users just use the TAB space to separate them. Remember the directories must be separated by colons (:).

Additonal Information About Paths

Some people may tell you to put a dot ( . ) in the beginning of your $path. This is NOT recommended. Ideally the "." should not be in the path at all. The "." means your WORKING directory. Some users put this in the beginning of their path so the shell will look first in the working directory, then in the other directories that follow. If you really want it in the path, it should go at the end. But the system path already contains "." so you really don't need it.

Setting Your Default Printer

The printing system provided by Solaris is LP. You can specify a default printer by setting the LPDEST variable.

Again, you must have at least ONE space between setenv, LPDEST and printer.name. For example, to have your printing jobs go to printer "msi" on Solaris, you would append your .cshrc to reflect the following:

setenv	LPDEST	msi

You can also set a default editor and insert aliases in your in .cshrc file. An example of this would be:

set path = ( $path /usr/unsup/bin )

setenv MANPATH $MANPATH:/usr/local/X11R5/man:/usr/unsup/man

setenv LPDEST msi

setenv EDITOR emacs

alias quota "/usr/sbin/quota -v"
The general rule is to put variable and aliases in your .cshrc file and stty, mesg, and other programs that generate output in your .login file. The programs which you want executed at login should go in your .login file.

How To Source Your .cshrc File

After you have made any changes to your .cshrc file, and you want these changes to take effect immediately, you will have to source your .cshrc file. source is a built-in C shell command. source will read and execute commands from a C shell script. To source your .cshrc file, do the following at your C shell prompt (%):
	% source ~/.cshrc

This will enable your changes to be read and executed, in the window in which you executed the source command. If you want these changes to take effect in all your windows, you must execute source in each window, or log out of the system and log back in again.

If you are a new user, you may have been given a C shell with your account (this is the default), but not a .cshrc file. If you execute at your prompt (%) an ls -al and do NOT see a file named .cshrc, you may want to create one.

For more information, at your system prompt, type:

	man csh

man alias

Advantages of Using C Shell:

Input/output redirection, Wildcard characters (metacharacters) for filename abbreviation, Shell variables for customizing your environment, Integer arithmetic, Access to previous commands (command history), Command name abbreviation (aliasing), A built-in command set for writing shell programs and Job control.

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: Aug 22, 2007 12:02 pm GMT-4 by admin
JumpURL: