18. Configuring your .cshrc File
Introduction to FreeBSD

This is the Standard .cshrc files that comes with your system.

#csh .cshrc file

alias h		history 25
alias j		jobs -l
alias la	ls -a
alias lf	ls -FA
alias ll	ls -lA
alias su	su -m

setenv	EDITOR	vi
setenv	EXINIT	'set autoindent'
setenv	PAGER	more

set path = (~/bin /bin /usr/{bin,games} /usr/local/bin /usr/X11R6/bin)

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set filec
	set history = 1000
	set ignoreeof
	set mail = (/var/mail/$USER)
	set mch = `hostname -s`
	set prompt = "${mch:q}: {\!} "
	umask 2
endif

The path statement tells your shell where to look for programs when you try to execute them. It starts with the first directory listed and looks there for any match to the command you have just entered. If it finds it, it executes that program.

If the directory is not listed in the path statement, it will not look there for executable files. Not even in your current directory. So even if you are in the same directory as the file you want to execute, it will not find it if that directory is not listed in your path statement.

If you want to execute a command in your current path, you have to precede the command with ``./''. For example, you are in the /usr/local/www/cgi-bin directory and want to test out a program you have written. The program is getdata.pl, and you have just tried to run it by typing getdata.pl, however instead of the HTML output you expect, you just get the error, getdata.pl: Command not found. This is because you did not include the ``.'' directory in your path statement. Remember that in UNIX, the ``.'' represents the current directory. To get this file to execute you would need to type:

./getdata.pl

Now you should see the HTML output you expect, unless you messed up in your program and then you will get error messages pertaining to the language you wrote the program in.

A TCSH Example

As we mentioned earlier, the tcsh has a few extra features over the base csh that make life on the command line a little easier. Here is an example .cshrc file that takes advantage of tcsh's goodies:

#tcsh .tcshrc file

alias h		history 25
alias j		jobs -l
alias la	ls -a
alias lf	ls -FA
alias ll	ls -lF
#alias su	su -m -- bad for su'ing to root..

setenv	EDITOR	vim
setenv	PAGER	less

set path = ( ~/bin /usr/local/bin /bin /usr/{bin,games} 
/usr/sbin /sbin /usr/local/samba/bin /usr/X11R6/bin /usr/local/java/bin .)

setenv IRCNICK ringzero
setenv IRCSERVER irc2.magic.ca
setenv NNTPSERVER news.sentex.ca

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set filec
	set fignore = .o		# ignore object files for filec
	set showmatch			# for programming
	set history = 100 
	set savehist = 75		# tcsh version of history..
	set ignoreeof
	set mail = (/var/mail/$USER)
	set prompt="vinyl:{%h}%~ %% "	# tcsh version of above!

	set watch = (1 gabor any mike any adrian any pwardrop any)

	umask 2
endif

The first things to note are the setenv lines. In this case, they are setting some environment variable that are used by my news reader software and IRC client software. The next point of interest is the set fignore = .o, which makes the file completion (set filec) ignore files that end in ``.o''. This is nice if you're a C programmer since you never would want to edit or manually do much with a .o file - you want the ``.c'' file! The showmatch option is another addition to the file completion mechanism of tcsh. Try it out and see what it does for yourself! The set prompt option sets up a very friendly prompt for your shell. It will show you what directory you are in all the time. Here's what it looks like:

mark:{123}~ % cd /usr/src
mark:{124}/usr/src %

Note that the tilde character (``~'') indicates your home directory. Now that you've seen some of what the tcsh and csh options are, the best way to learn more about them is to man tcsh! All of the features of both shells (such as the ``watch'' feature of tcsh) are documented in the man pages. Go ahead and take a look and experiment to see what fun tricks you prefer!

Note:

If you change your .cshrc file, you can re-read the changes by issuing a source .cshrc!

Return to Table of Contents

Visit the Gifcom