4bsd .login and .cshrc

Jacob Gore gore at eecs.nwu.edu
Mon Mar 28 06:32:37 AEST 1988


/ comp.unix.questions / gandalf at csli.STANFORD.EDU (Juergen Wagner) / Mar 27, 1988 /
>The point is that .cshrc is executed every time a csh starts ([...]).
>Put in this file everything you'd like to have in every csh. Put into 
>.login everything you need in the login shell, and all environment variables 
>not needed in all cshs. Also, terminal setup (tset, stty, biff, ...) should 
>be in .login because in .cshrc it doesn't make sense.

I find that this sequence (.cshrc first, then .login) is the opposite of what
I want.  That is because I want to set up environment variables just once --
in .login, -- and I want them to be usable from .cshrc in each shell I use,
including the login shell.

So, I just reverse them:

.login (abbridged):

	setenv EDITOR /usr/local/bin/mg
	unset autologout
	set prompt="%m"; setenv SHOSTNAME $prompt
	biff y
	setenv HAVELOGGEDIN yes
	source ~/.tcshrc

.tcshrc (abbridged):

	if (${?HAVELOGGEDIN}) then
	  source ~/.customrc
	  set prompt="`whoami`@${SHOSTNAME}> "
	  set history=50 savehist=20
	endif

This way, when the login shell starts up, .tcshrc skips itself (because
HAVELOGGEDIN is not defined), .login is run, and it runs .tcshrc when it's
finished. 

On subsequent shells, just the .tcshrc is run, and it executes normally.

Jacob Gore				Gore at EECS.NWU.Edu
Northwestern Univ., EECS Dept.		{oddjob,gargoyle,ihnp4}!nucsrl!gore



More information about the Comp.unix.questions mailing list